public ActionResult Create(MVC5Templates.Models.OrderViewModel orderViewModel) { if (ModelState.IsValid) { using(var db = new NorthWndContext()) { db.Orders.Add(orderViewModel.Order); db.SaveChanges(); } return RedirectToAction("Index"); } orderViewModel = RefreshViewModel(orderViewModel); return View(orderViewModel); }
public ActionResult Edit(MVC5Templates.Models.OrderViewModel orderViewModel) { if (ModelState.IsValid) { using(var db = new NorthWndContext()) { db.Entry(orderViewModel.Order).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } orderViewModel = RefreshViewModel(orderViewModel); return View(orderViewModel); }