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