public async Task <ProfileReference> Handle(CreateProfileCommand request, CancellationToken cancellationToken) { var sameNameExists = await _profileRepository.CheckProfileExistsAsync(request.Name); if (sameNameExists) { throw new AtlasBusinessException($"A profile with the name {request.Name} already exists."); } _unitOfWork.BeginTransaction(); try { var profile = ConvertToProfile(request); var profileId = await _profileRepository.CreateProfileAsync(profile); _unitOfWork.Commit(); _logger.LogInformation("New profile created with id {Atlas_ProfileId}.", profileId); return(new ProfileReference { ProfileId = profileId, Name = profile.Name }); } catch { _unitOfWork.Rollback(); throw; } }