コード例 #1
0
        public async Task ExecuteAsync(AddCustomEntityDraftVersionCommand command, IExecutionContext executionContext)
        {
            var definitionCode = await QueryVersionAndGetDefinitionCode(command).FirstOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(definitionCode, command.CustomEntityId);

            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);
            _permissionValidationService.EnforceCustomEntityPermission <CustomEntityUpdatePermission>(definitionCode, executionContext.UserContext);

            var newVersionId = await _customEntityStoredProcedures.AddDraftAsync(
                command.CustomEntityId,
                command.CopyFromCustomEntityVersionId,
                executionContext.ExecutionDate,
                executionContext.UserContext.UserId.Value);

            command.OutputCustomEntityVersionId = newVersionId;
            _customEntityCache.Clear(definitionCode, command.CustomEntityId);

            await _messageAggregator.PublishAsync(new CustomEntityDraftVersionAddedMessage()
            {
                CustomEntityId             = command.CustomEntityId,
                CustomEntityVersionId      = newVersionId,
                CustomEntityDefinitionCode = definitionCode
            });
        }
コード例 #2
0
        public async Task ExecuteAsync(UpdateCurrentUserPasswordCommand command, IExecutionContext executionContext)
        {
            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);

            var user = await GetUser(command, executionContext);

            UpdatePassword(command, executionContext, user);
            await _dbContext.SaveChangesAsync();
        }
コード例 #3
0
        private IQueryable <User> QueryUser(UpdateCurrentUserUserPasswordCommand command, IExecutionContext executionContext)
        {
            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);

            var user = _dbContext
                       .Users
                       .FilterCanLogIn()
                       .FilterById(executionContext.UserContext.UserId.Value);

            return(user);
        }
コード例 #4
0
        protected void CheckAdditionalPermissionHandlers <TCommandHandler>(TCommandHandler _commandHandler, IExecutionContext executionContext, IPermissionValidationService _permissionValidationService)
        {
            // Hardcoded checking of a few additional handlers, but could use DI here to make this more flexible.
            if (_commandHandler is ILoggedInPermissionCheckHandler)
            {
                _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);
            }

            if (_commandHandler is ICofoundryUserPermissionCheckHandler)
            {
                _permissionValidationService.EnforceHasPermissionToUserArea(CofoundryAdminUserArea.AreaCode, executionContext.UserContext);
            }
        }
コード例 #5
0
        public async Task ExecuteAsync(UpdateVisualEditorSettingsCommand command, IExecutionContext executionContext)
        {
            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);

            var allSettings = await _dbContext
                              .Settings
                              .ToListAsync();

            _settingCommandHelper.SetSettingProperty(command, c => c.VisualEditorDeviceView, allSettings, executionContext);

            await _dbContext.SaveChangesAsync();

            _settingCache.Clear();
        }
        public async Task ExecuteAsync(UpdateCurrentUserAccountCommand command, IExecutionContext executionContext)
        {
            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);
            var userId = executionContext.UserContext.UserId.Value;

            var user = await _dbContext
                       .Users
                       .FilterCanLogIn()
                       .FilterById(userId)
                       .SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(user, userId);

            await UpdateEmailAsync(command, userId, user, executionContext);

            user.FirstName = command.FirstName.Trim();
            user.LastName  = command.LastName.Trim();

            await _dbContext.SaveChangesAsync();
        }
コード例 #7
0
        public async Task ExecuteAsync(AddCustomEntityDraftVersionCommand command, IExecutionContext executionContext)
        {
            var definitionCode = await QueryVersionAndGetDefinitionCode(command).FirstOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(definitionCode, command.CustomEntityId);

            _permissionValidationService.EnforceIsLoggedIn(executionContext.UserContext);
            _permissionValidationService.EnforceCustomEntityPermission <CustomEntityUpdatePermission>(definitionCode, executionContext.UserContext);

            var newVersionId = await _customEntityStoredProcedures.AddDraftAsync(
                command.CustomEntityId,
                command.CopyFromCustomEntityVersionId,
                executionContext.ExecutionDate,
                executionContext.UserContext.UserId.Value);

            command.OutputCustomEntityVersionId = newVersionId;

            await _transactionScopeFactory.QueueCompletionTaskAsync(_dbContext, () => OnTransactionComplete(
                                                                        command,
                                                                        definitionCode,
                                                                        newVersionId)
                                                                    );
        }