namespace Brizco.Repository.Handlers.Complexes; public class CreateComplexCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler { private readonly ICurrentUserService _currentUserService = currentUserService; public async Task Handle(CreateComplexCommand request, CancellationToken cancellationToken) { try { await repositoryWrapper.BeginTransaction(cancellationToken); var complex = Complex.Create(request.Name, request.Address, request.SupportPhone); repositoryWrapper.SetRepository().Add(complex); await repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.CommitAsync(cancellationToken); return complex.AdaptToSDto(); } catch (Exception) { await repositoryWrapper.RollBackAsync(cancellationToken); throw; } } }