// GET: /Order/Create public ActionResult Create() { OrderCreateViewModel model = new OrderCreateViewModel(); model.Customers = GetAllCustomers(); model.ShipTypes = GetAllShipTypes(); model.EstimatedShipDate = DateTime.Now; //NO VIEWBAG: ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "FirstName"); return View(model); }
public ActionResult Create(OrderCreateViewModel order) { if (ModelState.IsValid) { //Get the order details to an Order Object. Order newOrder = Mapper.Map<OrderCreateViewModel, Order>(order); _orderRepository.Create(newOrder); _orderRepository.Save(); return RedirectToAction("Index"); } order.Customers = GetAllCustomers(); order.ShipTypes = GetAllShipTypes(); return View(order); }