public ActionResult Create([Bind(Include = "Id,TestId,TestGroupId")] TestGroupBind testGroupBind) { if (ModelState.IsValid) { db.TestGroupBinds.Add(testGroupBind); db.SaveChanges(); var atanacakTestGrubu = testGroupBind.TestGroupId; var atanacakOgrenciler = db.OgrenciAvatars.Where(k => k.TestGroups.Any(c => c.TestGroupId == atanacakTestGrubu)).ToList(); foreach (var ogrenci in atanacakOgrenciler) { OgrTestTakip ogrTestTakip = new OgrTestTakip(); ogrTestTakip.OgrenciId = ogrenci.Id; ogrTestTakip.TestGroupId = testGroupBind.TestGroupId; ogrTestTakip.TestId = testGroupBind.TestId; ogrTestTakip.AtanmaTarihi = DateTime.Now; db.OgrTestTakips.Add(ogrTestTakip); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.TestId = new SelectList(db.Tests, "Id", "Name", testGroupBind.TestId); ViewBag.TestGroupId = new SelectList(db.TestGroups, "Id", "Name", testGroupBind.TestGroupId); return(View(testGroupBind)); }
public ActionResult DeleteConfirmed(int id) { OgrTestTakip ogrTestTakip = db.OgrTestTakips.Find(id); db.OgrTestTakips.Remove(ogrTestTakip); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,OgrenciId,TestGroupId,TestId,AtanmaTarihi,TamamlanmaTarihi,CevapList")] OgrTestTakip ogrTestTakip) { if (ModelState.IsValid) { db.Entry(ogrTestTakip).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OgrenciId = new SelectList(db.OgrenciAvatars, "Id", "OgrName", ogrTestTakip.OgrenciId); ViewBag.TestGroupId = new SelectList(db.TestGroups, "Id", "Name", ogrTestTakip.TestGroupId); ViewBag.TestId = new SelectList(db.Tests, "Id", "Name", ogrTestTakip.TestId); return(View(ogrTestTakip)); }
// GET: OgrTestTakips/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OgrTestTakip ogrTestTakip = db.OgrTestTakips.Find(id); if (ogrTestTakip == null) { return(HttpNotFound()); } return(View(ogrTestTakip)); }
// GET: OgrTestTakips/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OgrTestTakip ogrTestTakip = db.OgrTestTakips.Find(id); if (ogrTestTakip == null) { return(HttpNotFound()); } ViewBag.OgrenciId = new SelectList(db.OgrenciAvatars, "Id", "OgrName", ogrTestTakip.OgrenciId); ViewBag.TestGroupId = new SelectList(db.TestGroups, "Id", "Name", ogrTestTakip.TestGroupId); ViewBag.TestId = new SelectList(db.Tests, "Id", "Name", ogrTestTakip.TestId); return(View(ogrTestTakip)); }