// GET: ShoppingList public ActionResult Index() { IndexViewModel vm = new IndexViewModel { Customers = ShoppingListService.GetCustomerSelectViewModel() }; return View(vm); }
// GET: ShoppingList public ActionResult Index() { ShoppingListService service = new ShoppingListService(); IndexViewModel vm = new IndexViewModel { Customers = service.GetItems() }; return View(vm); }
// GET: ShoppingList public ActionResult Index() { IndexViewModel vm = new IndexViewModel { FirstName = "Cade", LastName = "Winter", Products = _service.GetItems() }; vm.Total = vm.Products.Sum(p => p.Price); return View(vm); }
// GET: Calculator public ActionResult Index() { Calculator calc = new Calculator { }; IndexViewModel vm = new IndexViewModel { Calc = calc }; return View(vm); }
// GET: Customers public ActionResult Index() { List<Products> products = new List<Products> { new Products {Name = "Apple", Price = 1.99m}, new Products {Name = "Eggs", Price = 3.29m}, new Products {Name = "Ice Cream", Price = 4.99m} }; List<Customer> customer = new List<Customer> { new Customer { ListOfProducts = products, LastName = "Fleming", FirstName = "Jeremy"} }; IndexViewModel vm = new IndexViewModel { Customers = customer }; return View(vm); }
// GET: ShoppingList public ActionResult Index(IndexViewModel vm) { return RedirectToAction("ShowCart", new {id = vm.SelectedId}); }
// GET: Products public ActionResult Index() { // create list of products var products = new List<Product> { new Product {Name="Milk", Price=2.33m}, new Product {Name="Eggs", Price=1.09m}, new Product {Name="Cheese", Price=12.00m} }; // assign products to view model var vm = new IndexViewModel { Products = products, FirstName = "Jay", LastName = "Schultz" }; // return view with view model return View(vm); }