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.Module.Api.Commands.Models.Customers;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Mediator;
namespace Grand.Module.Api.Commands.Handlers.Customers;
public class DeleteCustomerAddressCommandHandler : IRequestHandler<DeleteCustomerAddressCommand, bool>
{
private readonly ICustomerService _customerService;
public DeleteCustomerAddressCommandHandler(ICustomerService customerService)
{
_customerService = customerService;
}
public async Task<bool> Handle(DeleteCustomerAddressCommand request, CancellationToken cancellationToken)
{
var customer = await _customerService.GetCustomerById(request.Customer.Id);
if (customer != null)
{
var address = customer.Addresses.FirstOrDefault(x => x.Id == request.Address.Id);
if (address != null) await _customerService.DeleteAddress(address, request.Customer.Id);
}
return true;
}
}