public async Task <GoogleAdto> ChangeAsync(ChangeGoogleAdto changeGoogleAdto)
        {
            using (ITransaction transaction = _transactionManager.Create())
            {
                try
                {
                    if (!(await _commandRepository.GetWithConcurrencyCheckAsync(changeGoogleAdto.Id, changeGoogleAdto.Version) is AuthenticationGrantTypeGoogle
                          authenticationGrantTypeGoogle))
                    {
                        throw new BusinessApplicationException(ExceptionType.NotFound, "Authentication service not found");
                    }

                    await _changeAuthenticationGrantTypeGoogleCommand.ExecuteAsync(authenticationGrantTypeGoogle,
                                                                                   _mapper.Map <ChangeGoogleAdto, ChangeAuthenticationGrantTypeGoogleDdto>(changeGoogleAdto));

                    await _commandRepository.UpdateAsync(authenticationGrantTypeGoogle);

                    transaction.Commit();

                    return(CreateGoogleAdto(authenticationGrantTypeGoogle));
                }
                catch (DomainValidationRuleException e)
                {
                    throw new BusinessValidationRuleApplicationException(e.ValidationResult);
                }
                catch (ConcurrencyDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.Concurrency, e);
                }
                catch (NotFoundDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.NotFound, e);
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> Put(
            Guid id,
            GoogleAuthenticationServiceResource resource)
        {
            ChangeGoogleAdto changeGoogleAdto = new ChangeGoogleAdto
            {
                Id                        = id,
                Name                      = resource.Name,
                ClientId                  = resource.ClientId,
                ClientSecret              = resource.ClientSecret,
                GrantAccessTokenUrl       = resource.GrantAccessTokenUrl,
                ValidateAccessTokenUrl    = resource.ValidateAccessTokenUrl,
                ClientGrantAccessTokenUrl = resource.ClientGrantAccessTokenUrl,
                Version                   = resource.Version
            };

            GoogleAdto googleAdto = await
                                    _googleAuthenticationServiceApplicationService.ChangeAsync(changeGoogleAdto);

            return(Ok(_resourceBuilder.Build(_mapper.Map <GoogleAdto, GoogleAuthenticationServiceResource>(googleAdto))));
        }
Пример #3
0
 public Task <GoogleAdto> ChangeAsync(ChangeGoogleAdto changeGoogleAdto)
 {
     return(_securityApplicationService.SecureAsync(() => _googleAuthenticationServiceApplicationService.ChangeAsync(changeGoogleAdto),
                                                    DefaultAuthorisationContext.Create(AuthorisationResource.AuthenticationService, AuthorisationAction.Update)));
 }