public IActionResult PlaceOrder(PizzaViewModel model) // model binding { UnitOfWork unitOfWork = new UnitOfWork(_db); ViewBag.MenuItems = unitOfWork.MenuItems.GetAll(); ViewBag.Sizes = unitOfWork.Sizes.GetAll(); ViewBag.Crusts = unitOfWork.Crusts.GetAll(); ViewBag.Toppings = unitOfWork.Toppings.GetAll(); if (ModelState.IsValid) { var size = unitOfWork.Sizes.Find(s => s.Name == model.Size).FirstOrDefault(); var crust = unitOfWork.Crusts.Find(c => c.Name == model.Crust).FirstOrDefault(); var pizza = new PizzaModel { Name = model.MenuItems, Size = size, Crust = crust }; pizza.ComputePrice(); List <PizzaModel> pizzas = new List <PizzaModel>(); pizzas.Add(pizza); OrderModel order = new OrderModel(); order.Pizzas = pizzas; order.ComputeOrderTotal(); order.GetDetails(); order.Date = DateTime.Now; unitOfWork.Orders.Add(order); unitOfWork.Complete(); unitOfWork.Dispose(); return(RedirectToAction("Orders")); } return(View("AddPizza", model)); }