BistroDriveWebApp.Controllers.ProfileController.DeleteDish C# (CSharp) Méthode

DeleteDish() private méthode

private DeleteDish ( int id ) : System.Web.Mvc.ActionResult
id int
Résultat System.Web.Mvc.ActionResult
        public ActionResult DeleteDish(int id)
        {
            dish item = DataManager.Dish.GetDishById(id);
            //защита от редактирования чужих блюд
            if (item.Id_User != User.Identity.GetUserId())
            {
                return RedirectToAction("index");
            }
            var old_file = item.ImageUrl;
            //чистим с БД
            DataManager.Dish.Delete(id);
            //удаляем изображение
            if (old_file != null)
            {
                var path = Server.MapPath(old_file);
                FileInfo fi = new FileInfo(path);
                try
                {
                    fi.Delete();
                }
                catch { }
            }
            return RedirectToAction("dish");
        }