//Change collection point public void changeCollectionPoint(BriefDept2 briefDept2) { string deptCode = briefDept2.deptCode; string collectionPointName = briefDept2.collectionPointName; var p = context.CollectionPoint.Where(x => x.CollectionPointName == collectionPointName).First(); int newCollectionPointId = p.CollectionPointId; var q = context.Department.Where(x => x.DepartmentCode == deptCode).First(); Department d = new Department(); d = q; d.CollectionPointId = newCollectionPointId; TimeSpan cutoff = TimeSpan.Parse("17:30"); // 5.30 PM TimeSpan now = DateTime.Now.TimeOfDay; if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday || DateTime.Now.DayOfWeek == DayOfWeek.Wednesday || DateTime.Now.DayOfWeek == DayOfWeek.Thursday || (DateTime.Now.DayOfWeek == DayOfWeek.Friday && now <= cutoff)) { var t = context.DisbursementList.Where(x => x.DepartmentCode == deptCode && x.Status == "Pending Delivery"); if (t.Any()) { DisbursementList dl = new DisbursementList(); dl = t.First(); dl.CollectionPointId = newCollectionPointId; } } context.SaveChanges(); }
//List collection points public List <BriefDept2> listCollectionPoints() { var q = context.CollectionPoint.ToList(); List <BriefDept2> list = new List <BriefDept2>(); foreach (CollectionPoint current in q) { BriefDept2 b = new BriefDept2(); b.collectionPointId = current.CollectionPointId; b.collectionPointName = current.CollectionPointName; list.Add(b); } return(list); }
//Get current collection point public BriefDept2 currentCollectionPoint(string dept) { var q = context.Department.Where(x => x.DepartmentCode == dept).First(); int collectionPointId = q.CollectionPointId; BriefDept2 d = new BriefDept2(); d.deptCode = dept; d.collectionPointId = collectionPointId; var t = context.CollectionPoint.Where(x => x.CollectionPointId == collectionPointId).First(); string collectionPointName = t.CollectionPointName; d.collectionPointName = collectionPointName; return(d); }
public void ChangeCollectionPoint(BriefDept2 briefDept2) { b.changeCollectionPoint(briefDept2); }