Ejemplo n.º 1
0
        public async Task <OperationResult> UpdateAsync(
            long guildId,
            long divisionId,
            CharacterGuildDivisionUpdateModel updateModel,
            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);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var performedById = _authenticationService.CurrentTicket !.UserId;

            var result = await _characterGuildDivisionsService.UpdateAsync(guildId, divisionId, updateModel, performedById, cancellationToken);

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <OperationResult> UpdateAsync(
            long guildId,
            long divisionId,
            CharacterGuildDivisionUpdateModel updateModel,
            ulong performedById,
            CancellationToken cancellationToken)
        {
            CharactersLogMessages.CharacterGuildDivisionUpdating(_logger, guildId, divisionId, updateModel, 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);
            }
            CharactersLogMessages.CharacterGuildIdValidationSucceeded(_logger, guildId);

            var nameValidationResult = await ValidateDivisionNameAsync(guildId, updateModel.Name, divisionId, cancellationToken);

            if (nameValidationResult.IsFailure)
            {
                CharactersLogMessages.CharacterGuildDivisionNameValidationFailed(_logger, updateModel.Name, nameValidationResult);
                return(nameValidationResult);
            }
            CharactersLogMessages.CharacterGuildDivisionNameValidationSucceeded(_logger, updateModel.Name);

            var now = _systemClock.UtcNow;

            var actionId = await _auditableActionsRepository.CreateAsync(
                (int)CharacterManagementAdministrationActionType.DivisionModified,
                now,
                performedById,
                cancellationToken);

            AuditingLogMessages.AuditingActionCreated(_logger, actionId);

            var updateResult = await _characterGuildDivisionsRepository.UpdateAsync(
                divisionId : divisionId,
                actionId : actionId,
                name : updateModel.Name,
                cancellationToken : cancellationToken);

            if (updateResult.IsFailure)
            {
                CharactersLogMessages.CharacterGuildDivisionUpdateFailed(_logger, guildId, divisionId, updateResult);
                return(updateResult);
            }
            CharactersLogMessages.CharacterGuildDivisionUpdated(_logger, guildId, divisionId);

            transactionScope.Complete();
            TransactionsLogMessages.TransactionScopeCommitted(_logger);

            return(OperationResult.Success);
        }
Ejemplo n.º 3
0
 public static void CharacterGuildDivisionUpdating(
     ILogger logger,
     long guildId,
     long divisionId,
     CharacterGuildDivisionUpdateModel updateModel,
     ulong performedById)
 => _characterGuildDivisionUpdating.Invoke(
     logger,
     guildId,
     divisionId,
     updateModel,
     performedById);