Esempio n. 1
0
        // GET: Orders/Create
        public ActionResult Create()
        {
			var vm = new MVC5Templates.Models.OrderViewModel();
			vm = RefreshViewModel(vm);

			return View(vm);
        }
Esempio n. 2
0
        // GET: Orders/Edit/5
		public ActionResult Edit(int? id)
        {
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            var order = _db.Orders.Find(id);
            if (order == null)
                return HttpNotFound();

			var orderViewModel = new MVC5Templates.Models.OrderViewModel();
			orderViewModel.Order = order;
			orderViewModel = RefreshViewModel(orderViewModel);

			return View(orderViewModel);
        }
Esempio n. 3
0
		private MVC5Templates.Models.OrderViewModel RefreshViewModel(OrderViewModel orderViewModel)
		{
			orderViewModel.Customers = _db.Customers.OrderBy(ob => ob.CompanyName).ToList();
			orderViewModel.Employees = _db.Employees.OrderBy(ob => ob.LastName).ToList();
			orderViewModel.Shippers = _db.Shippers.OrderBy(ob => ob.CompanyName).ToList();

			return orderViewModel;
		}