コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }