Example #1
0
        public ICommandResult Handle(UserUpdatePassawordCommand command)
        {
            if (command.Password != command.ConfirmPassword)
            {
                return(new GenericCommandResult(false, "Confirmação de senha diferente da senha", null));
            }

            var user = _userRepository.GetById(command.Id);

            user.UpdatePassword(HashingBCrypt.HashPassword(command.Password));
            if (!user.IsValid)
            {
                return(new GenericCommandResult(false, "Dados inválido", user.ValidationResult.Errors));
            }

            _userRepository.Update(user);

            return(new GenericCommandResult(true, "Senha do usuário atualizado com sucesso", null));
        }
Example #2
0
 public ActionResult <GenericCommandResult> UpdatePass([FromBody] UserUpdatePassawordCommand command)
 {
     return(Ok((GenericCommandResult)_handler.Handle(command)));
 }