public async Task <IActionResult> GetAlls() { var lists = await _service.GetAllAsync(); return(Ok(lists)); }
public async Task <List <ReceiveNoMain> > ReceiveNoMain(MaterialMainViewModel model) { var packingList = await _packingListService.GetAllAsync(); var packingListDetail = await _packingListDetailService.GetAllAsync(); var materialList = new List <Material_Dto>(); if (model.Missing_No == "") { materialList = await _repoPurchase.GetAll().ProjectTo <Material_Dto>(_configMapper) .Where(x => x.Purchase_No.Trim() == model.Purchase_No.Trim()).ToListAsync(); } else { materialList = await _repoMissing.GetAll().ProjectTo <Material_Dto>(_configMapper) .Where(x => x.Purchase_No.Trim() == model.Purchase_No.Trim()).ToListAsync(); } var data = (from a in packingList join b in packingListDetail on a.Receive_No.Trim() equals b.Receive_No.Trim() where a.Purchase_No.Trim() == model.Purchase_No.Trim() select new { Status = model.Status, Purchase_No = model.Purchase_No, Delivery_No = a.Delivery_No, Missing_No = model.Missing_No, MO_No = model.MO_No, Receive_No = a.Receive_No, MO_Seq = a.MO_Seq, Material_ID = a.Material_ID, Material_Name = a.Material_Name, Receive_Date = a.Receive_Date, Purchase_Qty = b.Purchase_Qty, Received_Qty = b.Received_Qty, Generated_QRCode = a.Generated_QRCode, Sheet_Type = a.Sheet_Type, Updated_By = a.Updated_By }).GroupBy(x => x.Receive_No).Select(cl => new ReceiveNoMain() { MO_No = cl.First().MO_No, Missing_No = cl.First().Missing_No, Purchase_No = cl.First().Purchase_No, Delivery_No = cl.First().Delivery_No, Receive_No = cl.First().Receive_No, MO_Seq = cl.First().MO_Seq, Material_ID = cl.First().Material_ID, Material_Name = cl.First().Material_Name, Receive_Date = cl.First().Receive_Date, Purchase_Qty = cl.Sum(c => c.Purchase_Qty), Accumated_Qty = cl.Sum(c => c.Received_Qty), Generated_QRCode = cl.First().Generated_QRCode, Sheet_Type = cl.First().Sheet_Type, Updated_By = cl.First().Updated_By }).OrderByDescending(x => x.Receive_Date).ToList(); foreach (var item1 in data) { var materialByPurchaseBath = materialList.Where(x => x.MO_Seq == item1.MO_Seq); var list1 = materialByPurchaseBath.GroupBy(x => x.Purchase_No).Select(cl => new { Accumated_Qty = cl.Sum(x => x.Accumlated_In_Qty) }).ToList(); item1.Accumated_Qty_All = list1[0].Accumated_Qty; } return(data); }