public async Task <ContaCriada> CriarContaSegura() { ContaCriada ret = null; var json = ""; var content = new StringContent(json, Encoding.UTF8, "application/json"); try { var response = await _client.PostAsync(Rotas.CriarConta, content); if (response.IsSuccessStatusCode) { string aux = response.Content.ReadAsStringAsync().Result; return(ContaCriada.FromJson(aux)); } else { switch (response.StatusCode) { case (System.Net.HttpStatusCode.Unauthorized): return(ret); case (System.Net.HttpStatusCode.BadRequest): return(ret); default: throw new HttpRequestException(); } } } catch (HttpRequestException e) { throw e; } catch (Exception e) { throw e; } }
public async Task <string> Novo(Cliente cliente) { string ret = null; try { SegurancaClienteHelper helper = new SegurancaClienteHelper(); ContaCriada conta = await helper.CriarContaSegura(); if (conta != null) { if (_repo.AbertaContaCliente(cliente, conta.NumeroConta)) { ret = conta.NumeroConta; } } } catch (Exception) { ret = null; } return(ret); }