public async Task <ListarCompraComAceiteResponse> ListarComAceite(ListarComprasComAceiteRequest request) { var response = new ListarCompraComAceiteResponse(); var handler = new HttpClientHandler(); //handler.ClientCertificates.Add(CertificadoRequisicao.Obter(this._dadosBhn.Certificado)); using (var httpClient = new HttpClient(handler)) { var listarComAceiteUrl = this._dadosLoja.RotaListarComAceite; httpClient.BaseAddress = new Uri(this._dadosLoja.ApiLojaAddressHost); httpClient.DefaultRequestHeaders.Accept.Clear(); var listarComAceiteRequest = new HttpRequestMessage(HttpMethod.Get, httpClient.BaseAddress + listarComAceiteUrl); using (var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json")) { listarComAceiteRequest.Content = content; var listarComAceiteResponse = await httpClient.SendAsync(listarComAceiteRequest); var responseString = await listarComAceiteResponse.Content.ReadAsStringAsync(); var responseObject = JsonConvert.DeserializeObject <ListarCompraComAceiteResponse>(responseString); return(responseObject); } } }
public async Task <ListarCompraComAceiteResponse> ListarComAceite(ListarComprasComAceiteRequest request) { var response = new ListarCompraComAceiteResponse(); try { var compras = await this._compraParceiroRepository.ListarComAceite(); response.ComprasParceiro = compras.Select(c => c.Map()).ToList(); response.Valido = true; } catch (ApplicationException appEx) { response.Valido = false; response.AdicionarMensagemErro(TipoMensagem.ErroNegocio, appEx.Message); } catch (Exception ex) { response.Valido = false; response.AdicionarMensagemErro(TipoMensagem.ErroAplicacao, ex.StackTrace); } return(response); }
public async Task <ActionResult> Get([FromQuery] ListarComprasComAceiteRequest request) { var response = await _service.ListarComAceite(request); return(this.GetHttpResponse(response)); }