Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

789 B
Raw Blame
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Domain.Shipping;
using Grand.Infrastructure.Events;
using Grand.Mediator;

namespace Grand.Business.Catalog.Events.Handlers;

public class DeliveryDateDeletedEventHandler : INotificationHandler<EntityDeleted<DeliveryDate>>
{
    private readonly IRepository<Product> _productRepository;

    public DeliveryDateDeletedEventHandler(IRepository<Product> productRepository)
    {
        _productRepository = productRepository;
    }

    public async Task Handle(EntityDeleted<DeliveryDate> notification, CancellationToken cancellationToken)
    {
        await _productRepository.UpdateManyAsync(x => x.DeliveryDateId == notification.Entity.Id,
            UpdateBuilder<Product>.Create().Set(x => x.DeliveryDateId, ""));
    }
}