public async Task <List <ListProductInSellRequest> > LoadListProduct(ListProductInSellRequest request) { var query = from p in _context.Products join pis in _context.ProductInSellBills on p.Id equals pis.ProductId select new { p, pis }; if (!string.IsNullOrEmpty(request.SellBillId)) { query = query.Where(x => x.pis.SellBillId.Contains(request.SellBillId)); } var data = await query .Select(x => new ListProductInSellRequest() { Name = x.p.Name, Price = x.p.Price, SellBillId = x.pis.SellBillId, TotalPrice = 1, OriginalPrice = 0, Discout = 0, }).ToListAsync(); return(data); }
public async Task <IActionResult> Index(ListProductInSellRequest request) { var data = await _sellApiClient.LoadListProduct(request); ViewData["data"] = data; var comboboxData = await _sellApiClient.GetName(); ViewData["combobox"] = comboboxData; return(View()); }
public async Task <List <ListProductInSellRequest> > LoadListProduct(ListProductInSellRequest request) { var client = _httpClientFactory.CreateClient(); client.BaseAddress = new Uri("https://localhost:5001"); var response = await client.GetAsync($"/api/Sell/LoadListProduct?SellBillId={request.SellBillId}"); var body = await response.Content.ReadAsStringAsync(); var data = JsonConvert.DeserializeObject <List <ListProductInSellRequest> >(body); return(data); }
public async Task <IActionResult> LoadListProduct([FromQuery] ListProductInSellRequest request) { var listProducts = await _sellService.LoadListProduct(request); return(Ok(listProducts)); }
public Task <IViewComponentResult> InvokeAsync(ListProductInSellRequest result) { return(Task.FromResult((IViewComponentResult)View("Default", result))); }