public async Task <OperationResult> UpdateExperienceDiffsAsync(
            IReadOnlyList <int> experienceDiffs,
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)CharacterAdministrationPermission.ManageLevels },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var performedById = _authenticationService.CurrentTicket !.UserId;

            var result = await _characterLevelsService.UpdateExperienceDiffsAsync(
                experienceDiffs,
                performedById,
                cancellationToken);

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Example #2
0
        public async Task <OperationResult> DeleteAsync(
            long guildId,
            long divisionId,
            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.DeleteAsync(guildId, divisionId, performedById, cancellationToken);

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
        public async ValueTask <OperationResult <IReadOnlyList <CharacterLevelDefinitionViewModel> > > GetDefinitionsAsync(
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)CharacterAdministrationPermission.ManageLevels },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var result = (await _characterLevelsService.GetCurrentDefinitionsAsync(cancellationToken))
                         .ToSuccess();

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Example #4
0
        public async Task <OperationResult <IReadOnlyCollection <CharacterGuildDivisionIdentityViewModel> > > GetIdentitiesAsync(
            long guildId,
            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 result = (await _characterGuildDivisionsService.GetCurrentIdentitiesAsync(guildId, cancellationToken))
                         .ToSuccess();

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Example #5
0
        public async Task <OperationResult <IReadOnlyCollection <UserOverviewViewModel> > > GetOverviewsAsync(
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)AdministrationPermission.ManageRoles },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var result = (await _usersRepository.AsyncEnumerateOverviews()
                          .ToArrayAsync(cancellationToken))
                         .ToSuccess <IReadOnlyCollection <UserOverviewViewModel> >();

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Example #6
0
        public async Task <OperationResult <UserDetailViewModel> > GetDetailAsync(
            ulong userId,
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)AdministrationPermission.ManageRoles },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var result = await _usersRepository.ReadDetailAsync(userId, cancellationToken);

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
Example #7
0
        public async Task <OperationResult> UpdateAsync(
            ulong userId,
            UserUpdateModel updateModel,
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)AdministrationPermission.ManageRoles },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var performedById = _authenticationService.CurrentTicket !.UserId;

            var result = await _usersService.UpdateAsync(userId, updateModel, performedById, cancellationToken);

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }
        public async ValueTask <OperationResult <IReadOnlyCollection <PermissionCategoryDescriptionViewModel> > > GetDescriptionsAsync(
            CancellationToken cancellationToken)
        {
            using var logScope = OperationLogMessages.BeginOperationScope(_logger, this);
            OperationLogMessages.OperationPerforming(_logger);

            OperationLogMessages.OperationAuthorizing(_logger);
            var authResult = await _authorizationService.RequirePermissionsAsync(
                new[] { (int)AdministrationPermission.ManagePermissions },
                cancellationToken);

            if (authResult.IsFailure)
            {
                OperationLogMessages.OperationNotAuthorized(_logger);
                return(authResult.Error);
            }
            OperationLogMessages.OperationAuthorized(_logger);

            var result = (await _permissionsService.GetDescriptionsAsync(cancellationToken))
                         .ToSuccess();

            OperationLogMessages.OperationPerformed(_logger, result);

            return(result);
        }