public ActionResult Sil(int id, string path) { using (KategoriRepository repo = new KategoriRepository()) { bool result; try { result = repo.Delete(id); } catch (Exception e) { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Kategor silinemedi. Kategoriye Bağlı Ürün Olabilir." } }; result = false; } if (result) { var message = ImageSaver.DeleteImage(path); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Kategori silindi" } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Kategor silinemedi." + message } }; return(RedirectToAction("Liste")); } return(RedirectToAction("Liste")); } }
public ActionResult Sil(int id, string path) { using (UrunRepository repo = new UrunRepository()) { bool result = repo.Delete(id); if (result) { var message = ImageSaver.DeleteImage(path); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Ürün silindi" } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Ürün silinemedi. </br>" + message } }; return(RedirectToAction("Liste")); } TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Ürün silinemedi. </br>" } }; return(RedirectToAction("Liste")); } }