public ActionResult Index() { var CAD = db.CustomerAccountDetails.ToList(); var customer = GetCustomer(); bool found = false; foreach (var item in CAD) { if (item.CustomerId == customer.ID) { found = true; } } if (found == true) { var susp = db.Suspensions.Where(x => x.CustomerId == customer.ID).ToList(); var pickups = db.PickUpRequests.Where(x => x.CustomerId == customer.ID).ToList(); var accountDet = db.CustomerAccountDetails.Where(x => x.CustomerId == customer.ID).FirstOrDefault(); CustomerAndAccountViewModel viewmodel = new CustomerAndAccountViewModel() { cust = customer, account = accountDet, pickups = pickups, suspensions = susp }; return(View(viewmodel)); } else { return(RedirectToAction("Initial")); } }
public ActionResult CustomerAccounts() { Employee employee = (Employee)TempData["employee"]; var accounts = db.CustomerAccountDetails.ToList(); var customers = db.Customers.Where(x => x.Zip == employee.Zip).ToList(); List <CustomerAccountDetails> filteredAccounts = new List <CustomerAccountDetails>(); foreach (var cust in customers) { foreach (var acc in accounts) { if (acc.CustomerId == cust.ID) { filteredAccounts.Add(acc); } } } GeoLocations Geo = new GeoLocations(); CustomerAndAccountViewModel view = new CustomerAndAccountViewModel() { accounts = filteredAccounts, customers = customers, geo = Geo }; EmployeeCustomerAccountsViewModel finalView = new EmployeeCustomerAccountsViewModel() { CustViewModel = view, emp = employee }; TempData["employee"] = employee; return(View(finalView)); }
public ActionResult EditProfile() { var customer = GetCustomer(); var acc = GetCustomerAccount(); CustomerAndAccountViewModel vm = new CustomerAndAccountViewModel() { cust = customer, account = acc }; vm.cust = customer; vm.account = acc; return(View(vm)); }
public ActionResult CustomerAccounts(string[] days, EmployeeCustomerAccountsViewModel finalView) { var currentEmployee = db.Employees.Where(x => x.Email == User.Identity.Name).FirstOrDefault(); var customers = db.Customers.Where(x => x.Zip == currentEmployee.Zip).ToList(); var accounts = db.CustomerAccountDetails.ToList(); List <CustomerAccountDetails> accResults = new List <CustomerAccountDetails>(); List <Customer> custResults = new List <Customer>(); foreach (var day in days) { foreach (var acc in accounts) { if (acc.WeeklyPickUpDay == day) { accResults.Add(acc); } } } foreach (var cust in customers) { foreach (var acc in accResults) { if (acc.CustomerId == cust.ID) { custResults.Add(cust); } } } Employee employee = (Employee)TempData["employee"]; CustomerAndAccountViewModel view = new CustomerAndAccountViewModel() { customers = custResults, accounts = accResults, }; finalView.CustViewModel = view; finalView.emp = employee; TempData["employee"] = employee; return(View(finalView)); }