public ActionResult Filter(CustomersByPickUpDay customer) { CustomersByPickUpDay customersList = new CustomersByPickUpDay(); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var employee = _context.Employees.Where(c => c.IdentityUserId == userId).SingleOrDefault(); var selection = customer.PickUpDaySelection; var customers = _context.Customers.Include(c => c.PickUpDay).ToList(); customersList.Customers = customers.Where(c => c.ZipCode == employee.ZipCodeAssignment && c.PickUpDay.Date == selection).ToList(); customersList.PickUpDaySelections = new SelectList(_context.PickUpDays, "Date", "Date"); return(View("Filter", customersList)); }
// GET: EmployeeController/Filter - this action pulls up a view with a drop down selectlist to allow filtering by Pick Up Day public ActionResult Filter() { // make an instance of the viewmodel CustomersByPickUpDay customersList = new CustomersByPickUpDay(); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var employee = _context.Employees.Where(c => c.IdentityUserId == userId).SingleOrDefault(); // find and attach individual properties of the viewmodel var customers = _context.Customers.Include(c => c.PickUpDay).ToList(); customersList.Customers = customers.Where(c => c.ZipCode == employee.ZipCodeAssignment).ToList(); customersList.PickUpDaySelections = new SelectList(_context.PickUpDays, "Date", "Date"); return(View(customersList)); }