public ActionResult ConfirmWeeklyPickup(int id) { var customer = db.Customers.Where(x => x.ID == id).FirstOrDefault(); var today = DateTime.Today.ToShortDateString(); var pickup = db.WeeklyPickups.Where(x => x.CustomerId == id).Where(x => x.Date == today).FirstOrDefault(); PickUpsViewModel pick = new PickUpsViewModel() { cust = customer, weeklypickup = pickup }; return(View(pick)); }
public ActionResult Index() { var employee = db.Employees.Where(x => x.Email == User.Identity.Name).FirstOrDefault(); TempData["employee"] = employee; var customers = db.Customers.Where(x => x.Zip == employee.Zip).ToList(); var custAcc = db.CustomerAccountDetails.Where(x => x.WeeklyPickUpDay == DateTime.Today.DayOfWeek.ToString()).ToList(); List <Customer> customersL = db.Customers.ToList(); PickUpsViewModel view = new PickUpsViewModel(); List <Customer> results = new List <Customer>(); List <WeeklyPickups> pickupResults = new List <WeeklyPickups>(); foreach (var account in custAcc) { foreach (var cust in customers) { if (cust.ID == account.CustomerId) { bool check = CheckSuspensions(cust.ID); if (check == false) { CreateWeekly(cust.ID); var today = DateTime.Today.ToShortDateString(); pickupResults.Add(db.WeeklyPickups.Where(x => x.CustomerId == cust.ID).Where(x => x.Date == today).FirstOrDefault()); results.Add(cust); } } } } var special = db.PickUpRequests.Where(x => x.Date == DateTime.Today).ToList(); List <PickUpRequests> filteredPickups = new List <PickUpRequests>(); foreach (var item in special) { foreach (var cust in customers) { if (cust.ID == item.CustomerId) { filteredPickups.Add(item); } } } view.weeklypickups = pickupResults; view.standardPickups = results; view.specialPickups = filteredPickups; view.customers = customersL; return(View(view)); }