// Cats.Models.Hub.CTSContext db = new CTSContext(); public virtual ActionResult SIReport(string siNumber) { if (!string.IsNullOrEmpty(siNumber)) { // TODO: redo this report var dispatches = from dis in _dispatchService.GetAllDispatch() where dis.DispatchDetails.FirstOrDefault().ToString() == siNumber.Trim() select dis; // TODO: redo this report var recieves = from res in _receiveService.GetAllReceive() where res.ReceiveDetails.FirstOrDefault().TransactionGroup.Transactions.FirstOrDefault().ShippingInstruction.Value == siNumber.Trim() select res; SIReportModel model = new SIReportModel(); foreach (Dispatch p in dispatches) { foreach (DispatchDetail com in p.DispatchDetails) { TransactedStock dis = new TransactedStock(); dis.Warehouse = p.Hub.Name; //dis.Store = p.Store.Name; dis.GIN = p.GIN; dis.Commodity = com.Commodity.Name; dis.Date = p.DispatchDate; dis.FDP = p.FDP.Name; //dis.Quantity = com.DispatchedQuantityInMT; dis.Region = p.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name; dis.Woreda = p.FDP.AdminUnit.Name; dis.Zone = p.FDP.AdminUnit.AdminUnit2.Name; model.Dispatched.Add(dis); } } foreach (Receive p in recieves) { foreach (ReceiveDetail com in p.ReceiveDetails) { TransactedStock dis = new TransactedStock(); dis.Warehouse = p.Hub.Name; //dis.Store = p.Store.Name; dis.GRN = p.GRN; dis.Commodity = com.Commodity.Name; dis.Date = p.ReceiptDate; //dis.Quantity = com.ReceivedQuantityInMT; model.Recieved.Add(dis); } } return(View(model)); } return(View(new SIReportModel())); }
// Cats.Models.Hub.CTSContext db = new CTSContext(); public virtual ActionResult SIReport(string siNumber) { if (!string.IsNullOrEmpty(siNumber)) { // TODO: redo this report var dispatches = from dis in _dispatchService.GetAllDispatch() where dis.DispatchDetails.FirstOrDefault().ToString() == siNumber.Trim() select dis; // TODO: redo this report var recieves = from res in _receiveService.GetAllReceive() where res.ReceiveDetails.FirstOrDefault().TransactionGroup.Transactions.FirstOrDefault().ShippingInstruction.Value == siNumber.Trim() select res; SIReportModel model = new SIReportModel(); foreach(Dispatch p in dispatches) { foreach(DispatchDetail com in p.DispatchDetails) { TransactedStock dis = new TransactedStock(); dis.Warehouse = p.Hub.Name; //dis.Store = p.Store.Name; dis.GIN = p.GIN; dis.Commodity = com.Commodity.Name; dis.Date = p.DispatchDate; dis.FDP = p.FDP.Name; //dis.Quantity = com.DispatchedQuantityInMT; dis.Region = p.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name; dis.Woreda = p.FDP.AdminUnit.Name; dis.Zone = p.FDP.AdminUnit.AdminUnit2.Name; model.Dispatched.Add(dis); } } foreach (Receive p in recieves) { foreach(ReceiveDetail com in p.ReceiveDetails) { TransactedStock dis = new TransactedStock(); dis.Warehouse = p.Hub.Name; //dis.Store = p.Store.Name; dis.GRN = p.GRN; dis.Commodity = com.Commodity.Name; dis.Date = p.ReceiptDate; //dis.Quantity = com.ReceivedQuantityInMT; model.Recieved.Add(dis); } } return View(model); } return View(new SIReportModel()); }