public List <CustomerViewModel> GetCustomerViewModelList() { CustomerBusinessLayer cutBL = new CustomerBusinessLayer(); List <Customer> customerList = cutBL.GetCustomer(); List <CustomerViewModel> cutLVM = new List <CustomerViewModel>(); foreach (Customer customer in customerList) { CustomerViewModel cutVM = new CustomerViewModel(); cutVM.CustomerName = customer.CustomerFirstName + " " + customer.CustomerLastName; cutVM.CustomerGender = customer.CustomerGender; cutVM.CustomerEmail = customer.CustomerEmail; cutVM.CustomerAddress = customer.CustomerStreetNum + " " + customer.CustomerStreetName + ", " + customer.CustomerProvince + ", " + customer.CustomerPostCode; cutVM.CustomerBillingMethod = customer.CustomerBillingMethod; cutLVM.Add(cutVM); } return(cutLVM); }
// GET: Customer public ActionResult Index() { CustomerListViewModel cusListModel = new CustomerListViewModel(); CustomerBusinessLayer cusBL = new CustomerBusinessLayer(); var listCus = cusBL.GetCustomer(); var listCusVm = new List <CustomerViewModel>(); foreach (var item in listCus) { CustomerViewModel cusVmObj = new CustomerViewModel(); cusVmObj.CustomerName = item.CustomerName; cusVmObj.Address = item.Address; listCusVm.Add(cusVmObj); } cusListModel.CustomerViewList = listCusVm; string greeting; //获取当前时间 DateTime dt = DateTime.Now; //获取当前小时 int hour = dt.Hour; if (hour < 12) { greeting = "早上好"; } else { greeting = "中午好"; } cusListModel.Greeting = greeting; cusListModel.UserName = "******"; return(View(cusListModel)); }