// GET: Sirket/Delete/5 public ActionResult Sil(int?id) { if (Session["yetki"] != null && (Session["yetki"].ToString() == "3" || Session["yetki"].ToString() == "4")) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sirket sirket = db.sirkets.Find(id); adre adres = db.adres.Where(m => m.adresID == sirket.sirketAdresID).FirstOrDefault(); List <iletisimToSirket> iletisimler = db.iletisimToSirkets.Where(m => m.sirketID == id).ToList(); if (sirket == null || adres == null || iletisimler == null) { return(HttpNotFound()); } for (int i = 0; i < iletisimler.Count(); i++) { db.iletisimToSirkets.Remove(iletisimler[i]); } db.adres.Remove(adres); db.sirkets.Remove(sirket); db.SaveChanges(); return(RedirectToAction("Liste")); } return(RedirectToAction("Login", "users")); }
// GET: Sirket/Details/5 public ActionResult Detay(int?id) { if (Session["id"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sirket sirket = db.sirkets.Find(id); adre adres = db.adres.Where(m => m.adresID == sirket.sirketAdresID).SingleOrDefault(); ViewBag.sirketAdres = adres; if (sirket == null) { return(HttpNotFound()); } return(View(sirket)); } return(RedirectToAction("Login", "users")); }