示例#1
0
        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));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TestGroupBind testGroupBind = db.TestGroupBinds.Find(id);

            db.TestGroupBinds.Remove(testGroupBind);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,TestId,TestGroupId")] TestGroupBind testGroupBind)
 {
     if (ModelState.IsValid)
     {
         db.Entry(testGroupBind).State = EntityState.Modified;
         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));
 }
示例#4
0
        // GET: TestGroupBinds/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestGroupBind testGroupBind = db.TestGroupBinds.Find(id);

            if (testGroupBind == null)
            {
                return(HttpNotFound());
            }
            return(View(testGroupBind));
        }
示例#5
0
        // GET: TestGroupBinds/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestGroupBind testGroupBind = db.TestGroupBinds.Find(id);

            if (testGroupBind == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TestId      = new SelectList(db.Tests, "Id", "Name", testGroupBind.TestId);
            ViewBag.TestGroupId = new SelectList(db.TestGroups, "Id", "Name", testGroupBind.TestGroupId);
            return(View(testGroupBind));
        }