public ActionResult Edit(int id) { Dinners dinner = dinnerRepository.GetDinner(id); // ViewData["Countries"] = new SelectList(PhoneValidator.Countries, dinner.Country); if (!dinner.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } return(View(new DinnerFormViewModel(dinner))); }
public ActionResult Edit(int id, FormCollection formValues) { Dinners dinner = dinnerRepository.GetDinner(id); if (!dinner.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } try { UpdateModel(dinner); dinnerRepository.Save(); return(RedirectToAction("Details", new { id = dinner.DinnerID })); } catch { // ModelState.AddModelErrors(dinner.GetRuleViolations()); return(View(new DinnerFormViewModel(dinner))); } }