public ActionResult Edit(NileModel model) { try { //Validate if (ModelState.IsValid) { //Save if valid var product = model.ToDomain(); _database.Update(product); //PRG return(RedirectToAction("Index", new { id = product.Id })); } ; } catch (Exception e) { ModelState.AddModelError("", e.Message); }; return(View(model)); }
public ActionResult Create(NileModel model) { try { //Validate if (ModelState.IsValid) { //Save if valid var product = model.ToDomain(); _database.Add(product); // PostRedirectGet return(RedirectToAction("Index")); } ; } catch (Exception e) { ModelState.AddModelError("", e.Message); }; return(View(model)); }