public ActionResult DeleteConfirmed(int id) { var eczaneNobetGrupDetay = _eczaneNobetGrupService.GetDetayById(id); //EczaneNobetGrup eczaneNobetGrup = _eczaneNobetGrupService.GetById(id); try { //PlanlananNobetleriYazdir(eczaneNobetGrup); _eczaneNobetGrupService.Delete(id); } catch (DbUpdateException ex) { var hata = ex.InnerException.ToString(); string[] referansKayitHatasi = { "The DELETE statement conflicted with the REFERENCE constraint", "with unique index" }; var referansKayitHatasiMi = referansKayitHatasi.Any(h => hata.Contains(h)); if (referansKayitHatasiMi) { throw new Exception($"Gruptan silmek istediğiniz <strong>{eczaneNobetGrupDetay.EczaneAdi} eczanesine ait başka kayıtlar bulunmaktadır.</strong> " + "Lütfen bu kayıtları sildikten sonra tekrar deneyiniz..." + "<br /> " + "<strong >(Önce referans kayıtlar silinmelidir!)</strong>", ex.InnerException); } throw ex; } catch (Exception ex) { throw ex; } return(RedirectToAction("Index")); }