Example #1
0
        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"));
        }
Example #2
0
        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"));
        }