using MediatR; using Modules.Library.Application.Gateways; namespace Modules.Library.Application.Commands.Dictionaries.Genre; public class SetGenreNameCommand : IRequest { public Guid Id { get; set; } = default!; public string Name { get; set; } = default!; } public class SetGenreNameCommandHandler(IGenreGateway genreGateway) : IRequestHandler { public async Task Handle(SetGenreNameCommand request, CancellationToken cancellationToken) { if (await genreGateway.IsGenreExists(request.Name, request.Id)) throw new Exception("Genre with the same name already exist"); await genreGateway.SetName(request.Id, request.Name); return Unit.Value; } }