Example #1
0
        public ResponseResult UpdateUserPassword(Guid userId, string newPassword, string newPasswordConfirm, string oldPassword)
        {
            try
            {
                if (newPassword != newPasswordConfirm || !_helper.ValidatePassword(newPassword))
                {
                    return(new ResponseResult("Неверные входные данные."));
                }

                return(new ResponseResult
                {
                    IsSuccess = _accountRepository.UpdateUserPassword(userId, newPassword, oldPassword)
                });
            }
            catch (Exception e)
            {
                const string ErrorMessage = "Не удалось обновить пароль пользователя.";
                _loggingService.Log(this, ErrorMessage, LogType.Error, e);
                return(new ResponseResult(ErrorMessage));
            }
        }
Example #2
0
        public ResponseResult CreateUser(UserInfo userInfo)
        {
            try
            {
                if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.Address) ||
                    string.IsNullOrWhiteSpace(userInfo.Country) || !_helper.ValidatePassword(userInfo.Password) ||
                    string.IsNullOrWhiteSpace(userInfo.Fio) || !_helper.ValidateEmail(userInfo.Email) ||
                    string.IsNullOrWhiteSpace(userInfo.Login) || !_helper.ValidatePhone(userInfo.Mobile) ||
                    !_helper.ValidatePhone(userInfo.Phone) || string.IsNullOrWhiteSpace(userInfo.Zip))
                {
                    return(new ResponseResult("Неверные входные данные"));
                }

                return(new ResponseResult {
                    IsSuccess = _administratorRepository.CreateUser(userInfo)
                });
            }
            catch (Exception exception)
            {
                _loggingService.Log(this, CreateUserException, LogType.Error, exception);
                return(new ResponseResult <bool>(CreateUserException));
            }
        }