public async Task <List <SaleListDTO> > GetSales(GetSalesDTO getSales, string apiCode) { GetSalesRequestDTO getSalesRequest = new GetSalesRequestDTO { ApiCode = apiCode, StoreId = getSales.StoreId, OrderStatus = getSales.OrderStatus, InvoiceStatus = getSales.InvoiceStatus }; using (var httpClient = new System.Net.Http.HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(getSalesRequest), Encoding.UTF8, "application/json"); ResponseEntity <GetSalesResponseDTO> responseObject; using (var response = await httpClient.PostAsync("https://e-out-test.stockmount.com/api/Integration/GetSales", content)) { response.EnsureSuccessStatusCode(); string responseStr = await response.Content.ReadAsStringAsync(); try { responseObject = JsonConvert.DeserializeObject <ResponseEntity <GetSalesResponseDTO> >(responseStr); return(convertToSaleListDTO(responseObject)); } catch (Exception ex) { throw ex; } } } }
public async Task <IActionResult> GetSales([FromBody] GetSalesDTO getSales) { var ident = User.Identity as ClaimsIdentity; var apiCode = ident.Claims.FirstOrDefault()?.Value; var salesObj = await _userService.GetSales(getSales, apiCode); return(Ok(salesObj)); }