public void CanSerializeAndDeserializeAClient() { var client = new Client { ClientId = "123", Enabled = true, AbsoluteRefreshTokenLifetime = 5, AccessTokenLifetime = 10, AccessTokenType = AccessTokenType.Jwt, AllowRememberConsent = true, RedirectUris = new System.Collections.Generic.List <Uri> { new Uri("http://foo.com") } }; var clientStore = new InMemoryClientStore(new Client[] { client }); var converter = new ClientConverter(clientStore); var settings = new JsonSerializerSettings(); settings.Converters.Add(converter); var json = JsonConvert.SerializeObject(client, settings); var result = JsonConvert.DeserializeObject <Client>(json, settings); Assert.AreSame(client, result); }
public ClientDTO getClientById(String clientId) { Client client = clientRepository.GetByID(clientId); if (client == null) { throw new InvalidOperationException("No client found with that clientId"); } return(ClientConverter.toDto(client)); }
public ResultGeneric <PostClientAccountResponse> Register(PostClientAccountRequest entity) { var accountCreate = new ResultGeneric <PostClientAccountResponse>(); var newClient = ClientConverter.Parse(entity); var newAccount = AccountConverter.Parse(entity); var clientID = new Guid(); #region Client var client = clientRepository.getByDocument(entity.CPF); if (client != null) { clientID = client.ClientID; } else { clientRepository.Insert(newClient); clientID = newClient.ClientID; } #endregion #region Account if (!accountRepository.AccountExists(entity.AgencyNumber, entity.AccountNumber)) { newAccount.ClientID = clientID; accountRepository.Insert(newAccount); accountCreate.Success = true; } else { accountCreate.Success = false; accountCreate.Errors.Add("Conta já existente"); } accountCreate.Data = ClientConverter.Parse(newClient, newAccount); #endregion return(accountCreate); }
public IEnumerable <ClientDTO> getAllClients() { return(ClientConverter.toDtos(clientRepository.Get())); }
public ClientBusinessImplementation(IClientRepository repository) { _repository = repository; _converter = new ClientConverter(); }