public ActionResult OgretmenIndex() { if (Convert.ToInt32(Session["kulTip"]) == 2 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { List <ogrenci_sube> osList = new List <ogrenci_sube>(); List <sube> sList = new List <sube>(); sList = db.ogretmen.Find(db.kullanicilar.Find(Convert.ToInt32(Session["kulId"])).ogretmen_id).ogretmenSubeler.Where(os => os.silindiMi == false && os.ogretmen.silindiMi == false && os.sube.silindiMi == false).Select(os => os.sube).ToList(); foreach (var item in sList.Where(s => s.silindiMi == false)) { foreach (var itemOgrenci in item.ogrenciSubeler.Where(os => os.silindiMi == false && os.ogrenci.silindiMi == false && os.sube.silindiMi == false)) { ogrenci_sube os = new ogrenci_sube(); os = itemOgrenci; osList.Add(os); } } return(View(osList)); } else { return(RedirectToAction("index", "giris")); } }
// GET: ogrenci_subeler/Delete/5 public ActionResult Delete(int?id) { if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ogrenci_sube ogrenci_sube = db.ogrenciSubeler.Find(id); if (ogrenci_sube == null) { return(HttpNotFound()); } ogrenci_sube.silindiMi = true; db.Entry(ogrenci_sube).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("index", "ogrenci_subeler")); } else { return(RedirectToAction("index", "giris")); } }
public ActionResult Create([Bind(Include = "id,ogrenci_id,sube_id,silindiMi")] ogrenci_sube ogrenci_sube) { if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { if (ModelState.IsValid) { if (db.ogrenciSubeler.Where(os => os.sube_id == ogrenci_sube.sube_id && os.silindiMi == false).Count() < 25) { db.ogrenciSubeler.Add(ogrenci_sube); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("uyari", "ogrenci_subeler")); } } ViewBag.ogrenci_id = new SelectList(db.ogrenciler, "id", "adSoyad", ogrenci_sube.ogrenci_id); ViewBag.sube_id = new SelectList(db.subeler, "id", "isim", ogrenci_sube.sube_id); return(View(ogrenci_sube)); } else { return(RedirectToAction("index", "giris")); } }
public ActionResult Edit([Bind(Include = "id,ogrenci_id,sube_id,silindiMi")] ogrenci_sube ogrenci_sube) { if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { if (ModelState.IsValid) { db.Entry(ogrenci_sube).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ogrenci_id = new SelectList(db.ogrenciler, "id", "adSoyad", ogrenci_sube.ogrenci_id); ViewBag.sube_id = new SelectList(db.subeler, "id", "isim", ogrenci_sube.sube_id); return(View(ogrenci_sube)); } else { return(RedirectToAction("index", "giris")); } }
// GET: ogrenci_subeler/Details/5 public ActionResult Details(int?id) { if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ogrenci_sube ogrenci_sube = db.ogrenciSubeler.Find(id); if (ogrenci_sube == null) { return(HttpNotFound()); } return(View(ogrenci_sube)); } else { return(RedirectToAction("index", "giris")); } }
// GET: ogrenci_subeler/Edit/5 public ActionResult Edit(int?id) { if (Convert.ToInt32(Session["kulTip"]) == 1 && !String.IsNullOrEmpty(Session["kulId"].ToString())) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ogrenci_sube ogrenci_sube = db.ogrenciSubeler.Find(id); if (ogrenci_sube == null) { return(HttpNotFound()); } ViewBag.ogrenci_id = new SelectList(db.ogrenciler.Where(o => o.silindiMi == false && o.devamDurumu == true), "id", "adSoyad", ogrenci_sube.ogrenci_id); ViewBag.sube_id = new SelectList(db.subeler.Where(s => s.silindiMi == false), "id", "isim", ogrenci_sube.sube_id); return(View(ogrenci_sube)); } else { return(RedirectToAction("index", "giris")); } }