public List <WCFRequestDept> getrequestdept(List <dynamic> rdlist) { List <WCFRequestDept> redelist = new List <WCFRequestDept>(); int available = 0; List <int> requested = new List <int>(); foreach (dynamic i in rdlist) { string itemdescription = i.Description; int quantityonhand = i.Actualqty; int requisitionid = i.RequisitionID; string deptname = i.DepartmentName; int deptneededquantity = i.deptneeded; int allocatedquantity = 0; string itemcode = i.itemcode; string bin = i.BIN; WCFRequestDept deitem = WCFRequestDept.Make(bin, itemdescription, quantityonhand, requisitionid, deptname, deptneededquantity, allocatedquantity, itemcode); redelist.Add(deitem); available = quantityonhand; } for (int j = 0; j < redelist.Count; j++) { for (int n = j + 1; n < redelist.Count; n++) { if (redelist[j].Deptname == redelist[n].Deptname) { if (redelist[j].Requisitionid < redelist[n].Requisitionid) { redelist[j].Deptneededquantity += redelist[n].Deptneededquantity; redelist.Remove(redelist[n]); } } } } foreach (WCFRequestDept it in redelist) { requested.Add(it.Deptneededquantity); } List <int> allocatedlist = scmanager.recommendDistribution(available, requested); for (int i = 0; i < allocatedlist.Count; i++) { redelist[i].Allocatedquantity = allocatedlist[i]; } return(redelist); }
public static WCFRequestDept Make(string bin, string itemdescription, int quantityonhand, int requisitionid, string deptname, int deptneededquantity, int allocatedquantity, string itemcode) { WCFRequestDept de = new WCFRequestDept(); de.Bin = bin; de.Itemdescription = itemdescription; de.Quantityonhand = quantityonhand; de.Requisitionid = requisitionid; de.Deptname = deptname; de.Deptneededquantity = deptneededquantity; de.Allocatedquantity = allocatedquantity; de.Itemcode = itemcode; return(de); }