public async Task <OperationResult <long> > CreateAsync( long guildId, CharacterGuildDivisionCreationModel creationModel, CancellationToken cancellationToken) { using var logScope = OperationLogMessages.BeginOperationScope(_logger, this); OperationLogMessages.OperationPerforming(_logger); OperationLogMessages.OperationAuthorizing(_logger); var authResult = await _authorizationService.RequirePermissionsAsync( new[] { (int)CharacterAdministrationPermission.ManageGuilds }, cancellationToken); if (authResult.IsFailure) { OperationLogMessages.OperationNotAuthorized(_logger); return(authResult.Error); } OperationLogMessages.OperationAuthorized(_logger); var performedById = _authenticationService.CurrentTicket !.UserId; var result = await _characterGuildDivisionsService.CreateAsync(guildId, creationModel, performedById, cancellationToken); OperationLogMessages.OperationPerformed(_logger, result); return(result); }
public static void CharacterGuildDivisionCreating( ILogger logger, long guildId, CharacterGuildDivisionCreationModel creationModel, ulong performedById) => _characterGuildDivisionCreating.Invoke( logger, guildId, creationModel, performedById);
public async Task <OperationResult <long> > CreateAsync( long guildId, CharacterGuildDivisionCreationModel creationModel, ulong performedById, CancellationToken cancellationToken) { CharactersLogMessages.CharacterGuildDivisionCreating(_logger, guildId, creationModel, performedById); using var transactionScope = _transactionScopeFactory.CreateScope(); TransactionsLogMessages.TransactionScopeCreated(_logger); var guildIdValidationResult = await ValidateGuildIdAsync(guildId, cancellationToken); if (guildIdValidationResult.IsFailure) { CharactersLogMessages.CharacterGuildIdValidationFailed(_logger, guildId, guildIdValidationResult); return(guildIdValidationResult.Error); } CharactersLogMessages.CharacterGuildIdValidationSucceeded(_logger, guildId); var nameValidationResult = await ValidateDivisionNameAsync(guildId, creationModel.Name, null, cancellationToken); if (nameValidationResult.IsFailure) { CharactersLogMessages.CharacterGuildDivisionNameValidationFailed(_logger, creationModel.Name, nameValidationResult); return(nameValidationResult.Error); } CharactersLogMessages.CharacterGuildDivisionNameValidationSucceeded(_logger, creationModel.Name); var actionId = await _auditableActionsRepository.CreateAsync( (int)CharacterManagementAdministrationActionType.DivisionCreated, _systemClock.UtcNow, performedById, cancellationToken); AuditingLogMessages.AuditingActionCreated(_logger, actionId); var divisionId = await _characterGuildDivisionsRepository.CreateAsync( guildId, creationModel.Name, actionId, cancellationToken); CharactersLogMessages.CharacterGuildDivisionCreated(_logger, guildId, divisionId); transactionScope.Complete(); TransactionsLogMessages.TransactionScopeCommitted(_logger); return(divisionId.ToSuccess()); }