科技动态

EpiEvents for Commerce

微信扫一扫,分享到朋友圈

EpiEvents for Commerce

Recently I have created an EpiEvents support for main Commerce events – InventoryUpdated and PriceUpdated.

Install the library using NuGet
:

Install-Package EpiEvents.Commerce

After installation, follow configuration documentation
.

Once, the library is installed in your project and configured correctly, you can start creating event handlers.

Here is an example of the PriceUdpated
event handler:

public class PriceUpdatedHandler : INotificationHandler
{
    private readonly ReferenceConverter _referenceConverter;
    private readonly IContentLoader _contentLoader;

    public PriceUpdatedHandler(ReferenceConverter referenceConverter, IContentLoader contentLoader)
    {
        _referenceConverter = referenceConverter;
        _contentLoader = contentLoader;
    }

    public void Handle(PriceUpdated notification)
    {
        foreach (var key in notification.CatalogKeys)
        {
            var link = _referenceConverter.GetContentLink(key.CatalogEntryCode);
            var content = _contentLoader.Get(link);

            // Do something with the content
        }
    }
}

InventoryUpdated event handler will look the same except that you have to pass the InventoryUpdated event type as a generic parameter.

For more information check GitHub repository
.

AT&T CEO describes new $15/month streaming service during antitrust testimony

上一篇

Setting up Prometheus Alertmanager

下一篇

你也可能喜欢

评论已经被关闭。

插入图片

热门栏目

EpiEvents for Commerce

长按储存图像,分享给朋友