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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
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 WarehouseDeletedEventHandler : INotificationHandler<EntityDeleted<Warehouse>>
{
private readonly IRepository<Product> _productRepository;
public WarehouseDeletedEventHandler(IRepository<Product> productRepository)
{
_productRepository = productRepository;
}
public async Task Handle(EntityDeleted<Warehouse> notification, CancellationToken cancellationToken)
{
await _productRepository.RemoveCollectionFieldItem(string.Empty, x => x.ProductWarehouseInventory,
z => z.WarehouseId == notification.Entity.Id);
await _productRepository.UpdateManyAsync(x => x.WarehouseId == notification.Entity.Id,
UpdateBuilder<Product>.Create().Set(x => x.WarehouseId, ""));
}
}