public IsHostedBy ( string userName ) : bool | ||
userName | string | |
Résultat | bool |
public ActionResult Edit(int id) { NerdDinner.Entities.Dinners dinner = dinnerRepository.GetDinner(id); if (!dinner.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } return(View(new DinnerFormViewModel(dinner))); }
public ActionResult Delete(int id) { NerdDinner.Entities.Dinners dinner = dinnerRepository.GetDinner(id); if (dinner == null) { return(View("NotFound")); } if (!dinner.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } return(View(dinner)); }
public ActionResult Edit(int id, FormCollection collection) { NerdDinner.Entities.Dinners dinner = dinnerRepository.GetDinner(id); if (!dinner.IsHostedBy(User.Identity.Name)) { return(View("InvalidOwner")); } try { UpdateModel(dinner); dinnerRepository.Save(dinner); return(RedirectToAction("Details", new { id = dinner.DinnerID })); } catch { ModelState.AddModelErrors(dinner.GetRuleViolations()); return(View(new DinnerFormViewModel(dinner))); } }