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.

738 B
Raw Blame
using Grand.Module.Api.Commands.Models.Common;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Mediator;

namespace Grand.Module.Api.Commands.Handlers.Common;

public class DeletePictureCommandHandler : IRequestHandler<DeletePictureCommand, bool>
{
    private readonly IPictureService _pictureService;

    public DeletePictureCommandHandler(IPictureService pictureService)
    {
        _pictureService = pictureService;
    }

    public async Task<bool> Handle(DeletePictureCommand request, CancellationToken cancellationToken)
    {
        var picture = await _pictureService.GetPictureById(request.PictureDto.Id);
        if (picture != null) await _pictureService.DeletePicture(picture);

        return true;
    }
}