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.Business.Core.Interfaces.Catalog.Products;
using Grand.Domain.Orders;
using Grand.Infrastructure.Events;
using Grand.Mediator;
namespace Grand.Business.Checkout.Events.ShoppingCart;
/// <summary>
/// Update order items
/// </summary>
public class ShoppingCartItemDeletedEventHandler : INotificationHandler<EntityDeleted<ShoppingCartItem>>
{
private readonly IProductReservationService _productReservationService;
public ShoppingCartItemDeletedEventHandler(IProductReservationService productReservationService)
{
_productReservationService = productReservationService;
}
public async Task Handle(EntityDeleted<ShoppingCartItem> notification, CancellationToken cancellationToken)
{
if ((notification.Entity.RentalStartDateUtc.HasValue && notification.Entity.RentalEndDateUtc.HasValue) ||
!string.IsNullOrEmpty(notification.Entity.ReservationId))
{
var reserved =
await _productReservationService.GetCustomerReservationsHelperBySciId(notification.Entity.Id);
foreach (var res in reserved) await _productReservationService.DeleteCustomerReservationsHelper(res);
}
}
}