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.

918 B
Raw Blame
using Grand.Business.Core.Interfaces.Marketing.Customers;
using Grand.Web.Commands.Models.Customers;
using Grand.Mediator;

namespace Grand.Web.Commands.Handler.Customers;

public class CurrentPositionCommandHandler : IRequestHandler<CurrentPositionCommand, bool>
{
    private readonly ICustomerCoordinatesService _customerCoordinateService;

    public CurrentPositionCommandHandler(ICustomerCoordinatesService customerCoordinateService)
    {
        _customerCoordinateService = customerCoordinateService;
    }

    public async Task<bool> Handle(CurrentPositionCommand request, CancellationToken cancellationToken)
    {
        ArgumentNullException.ThrowIfNull(request.Customer);
        ArgumentNullException.ThrowIfNull(request.Model);

        await _customerCoordinateService.SaveGeoCoordinate(request.Customer, request.Model.Longitude,
            request.Model.Latitude);

        return true;
    }
}