public ActionResult getCongNo(SearchingStockViewModel model) { Request.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); var NoDauKy = new List <DebtStockGroupViewModel>(); var NoCuoiKy = new List <DebtStockGroupViewModel>(); var tonDauModel = new SearchingStockViewModel(); tonDauModel.End = model.Start; model.Start = null; if (model.End == null) { model.End = DateTime.Now.Date; } NoDauKy = _debtnote.GetDebtInStock(tonDauModel).ToList(); NoCuoiKy = _debtnote.GetDebtInStock(model).ToList(); var test = new List <CongNoItem>(); var test1 = new CongNoItem(); if (NoDauKy.Count() != 0 && NoCuoiKy.Count() != 0) { foreach (var item in NoDauKy) { test1 = new CongNoItem(); test1.NoDauKy = item.Sum; test1.WarehouseName = item.Warehouse; test.Add(test1); } foreach (var item in NoCuoiKy) { foreach (var item1 in test) { if (item.Warehouse == item1.WarehouseName) { item1.NoCuoiKy = item.Sum; } } var check = NoDauKy.FirstOrDefault(x => x.Warehouse == item.Warehouse); if (check == null) { test1 = new CongNoItem(); test1.NoDauKy = 0; test1.WarehouseName = item.Warehouse; test1.NoCuoiKy = item.Sum; test.Add(test1); } } } else if (NoDauKy.Count() == 0 && NoCuoiKy.Count() != 0) { foreach (var item in NoCuoiKy) { test1 = new CongNoItem(); test1.NoCuoiKy = item.Sum; test1.NoDauKy = 0; test1.WarehouseName = item.Warehouse; test.Add(test1); } } else if (NoCuoiKy.Count() == 0 && NoDauKy.Count() != 0) { foreach (var item in NoDauKy) { test1 = new CongNoItem(); test1.NoCuoiKy = 0; test1.NoDauKy = item.Sum; test1.WarehouseName = item.Warehouse; test.Add(test1); } } return(Json(test, JsonRequestBehavior.AllowGet)); }
public IEnumerable <DebtStockGroupViewModel> GetDebtInStock([FromUri] SearchingStockViewModel model) { return(_debtNote.GetDebtInStock(model)); }