private Delete ( int id ) : System.Web.Mvc.ActionResult | ||
id | int | |
return | System.Web.Mvc.ActionResult |
public ActionResult Delete(int id)
{
var selectedEvent = eventRepository.Events.Where(x => x.EventId == id).FirstOrDefault();
if (selectedEvent.Creator.Equals(HttpContext.User.Identity.Name))
{
eventRepository.DeleteEvent(selectedEvent);
this.Success("The Event has been deleted.");
return RedirectToAction("Index");
}
else
{
this.Error("You can only delete events you created.");
return RedirectToAction("Details", new { id = id });
}
}