Beispiel #1
0
        public void Execute(UpdateCurrentUserUserPasswordCommand command, IExecutionContext executionContext)
        {
            var user = QueryUser(command, executionContext).SingleOrDefault();

            UpdatePassword(command, executionContext, user);
            _dbContext.SaveChanges();
        }
        public void Execute(DeleteUserCommand command, IExecutionContext executionContext)
        {
            var user         = QueryUser(command.UserId).SingleOrDefault();
            var executorRole = _userCommandPermissionsHelper.GetExecutorRole(executionContext);

            ValidateCustomPermissions(user, executionContext, executorRole);
            MarkRecordDeleted(user, executionContext);
            _dbContext.SaveChanges();
        }
Beispiel #3
0
        public void Execute(UpdateUnstructuredDataDependenciesCommand command, IExecutionContext executionContext)
        {
            var existingDependencies = QueryDepenencies(command).ToList();
            var relations            = GetDistinctRelations(command.Model);
            var ensureEntityDefinitionExistsCommands = GetEntityCheckCommands(command, existingDependencies, relations);

            foreach (var ensureEntityDefinitionExistsCommand in ensureEntityDefinitionExistsCommands)
            {
                _commandExecutor.Execute(ensureEntityDefinitionExistsCommand, executionContext);
            }
            ApplyChanges(command, existingDependencies, relations);
            _dbContext.SaveChanges();
        }
        public void Execute(LogAuthenticatedUserInCommand command, IExecutionContext executionContext)
        {
            var user = Query(command.UserId).SingleOrDefault();

            EntityNotFoundException.ThrowIfNull(user, command.UserId);

            var connectionInfo = _clientConnectionService.GetConnectionInfo();

            SetLoggedIn(user, executionContext);
            _dbContext.SaveChanges();

            _sqlExecutor.ExecuteCommand("Cofoundry.UserLoginLog_Add",
                                        new SqlParameter("UserId", user.UserId),
                                        new SqlParameter("IPAddress", connectionInfo.IPAddress),
                                        new SqlParameter("DateTimeNow", executionContext.ExecutionDate)
                                        );
        }
Beispiel #5
0
        public void Execute(AddUserCommand command, IExecutionContext executionContext)
        {
            var userArea   = _userAreaRepository.GetByCode(command.UserAreaCode);
            var dbUserArea = QueryUserArea(userArea).SingleOrDefault();

            dbUserArea = AddUserAreaIfNotExists(userArea, dbUserArea);

            ValidateCommand(command, userArea);
            var isUnique = _queryExecutor.Execute(GetUniqueQuery(command, userArea), executionContext);

            ValidateIsUnique(isUnique, userArea);

            var newRole = _userCommandPermissionsHelper.GetAndValidateNewRole(command.RoleId, command.UserAreaCode, executionContext);

            var user = MapAndAddUser(command, executionContext, newRole, userArea, dbUserArea);

            _dbContext.SaveChanges();

            command.OutputUserId = user.UserId;
        }
Beispiel #6
0
        public void ResetPassword(User user, IResetUserPasswordCommand command, IExecutionContext executionContext)
        {
            ValidateUserAccountExists(user);
            ValidateUserArea(user.UserAreaCode);

            var existingIncompleteRequests = QueryIncompleteRequests(user).ToList();

            SetExistingRequestsComplete(existingIncompleteRequests);
            var request = CreateRequest(executionContext, user);

            SetMailTemplate(command, user, request);

            using (var scope = _transactionScopeFactory.Create())
            {
                _dbContext.SaveChanges();
                _mailService.Send(user.Email, user.GetFullName(), command.MailTemplate);

                scope.Complete();
            }
        }
Beispiel #7
0
        public void Execute(CompleteUserPasswordResetCommand command, IExecutionContext executionContext)
        {
            var validationResult = _queryExecutor.Execute(CreateValidationQuery(command));

            ValidatePasswordRequest(validationResult);

            var request = QueryPasswordRequestIfToken(command).SingleOrDefault();

            EntityNotFoundException.ThrowIfNull(request, command.UserPasswordResetRequestId);

            UpdatePasswordAndSetComplete(request, command, executionContext);
            SetMailTemplate(command, request.User);

            using (var scope = _transactionScopeFactory.Create())
            {
                _dbContext.SaveChanges();
                _mailService.Send(request.User.Email, request.User.GetFullName(), command.MailTemplate);

                scope.Complete();
            }
        }