public ActionResult Delete(int id) { var dbCar = repo.GetByID(id); if (dbCar.Owner != LoginSession.Current.UserID) { return(RedirectToAction("Car", "UserCars")); } repo.DeleteByID(id); return(RedirectToAction("Index")); }
public ActionResult Delete(int id = 0) { if (!LoginUserSession.Current.IsAdministrator) { return(Edit()); } CarsRepository repo = new CarsRepository(); if (repo.GetByID(id) != null) { repo.DeleteByID(id); TempData["Message"] = "Successfully deleted car!"; } else { TempData["ErrorMessage"] = "No such car!"; } return(RedirectToAction("Edit")); }