Ejemplo n.º 1
0
        public async Task <PasswordAdto> ChangePasswordAsync(ChangePasswordAdto changePasswordAdto)
        {
            using (ITransaction transaction = _transactionManager.Create())
            {
                try
                {
                    Identity identity = await _identityCommandRepository.GetWithConcurrencyCheckAsync(changePasswordAdto.IdentityId, changePasswordAdto.Version);

                    if (identity == null)
                    {
                        throw new BusinessApplicationException(ExceptionType.NotFound, "Identity does not exist");
                    }

                    await _changePasswordCommand.ExecuteAsync(identity, new ChangePasswordCommandDdto
                    {
                        Password        = changePasswordAdto.Password,
                        ConfirmPassword = changePasswordAdto.ConfirmPassword
                    });

                    await _identityCommandRepository.UpdateAsync(identity);

                    transaction.Commit();

                    return(new PasswordAdto
                    {
                        IdentityId = identity.Id
                    });
                }
                catch (PasswordNotSetDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.NotFound, e);
                }
                catch (ConcurrencyDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.Concurrency, e);
                }
                catch (DomainValidationRuleException e)
                {
                    throw new BusinessValidationRuleApplicationException(e.ValidationResult);
                }
                catch (NotFoundDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.NotFound, e);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> ChangePasswordAsync(ChangePasswordViewModel model)
        {
            var result = await _changePasswordCommand.ExecuteAsync(model);

            return(StatusCode(result.GetStatusCode(), result.GetData()));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> ChangePasswordAsync(ChangePasswordViewModel model)
        {
            var result = await _changePasswordCommand.ExecuteAsync(model);

            return(new ObjectResult(result));
        }