예제 #1
0
        public ActionResult Create(string tenMonHoc, string tenGiangVien, int khoaHoc, string nganhHoc)
        {
            var daotao = new DaoTao(tenMonHoc, tenGiangVien, khoaHoc, nganhHoc);
            if (ModelState.IsValid)
            {
                db.daoTaos.Add(daotao);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(daotao);
        }
예제 #2
0
        public void TestCreateDaoTao()
        {
            DaoTao dt = new DaoTao(nameMonHoc, nameGiangVien, khoa, nganh);
            dt.ID = id;
            var daoTaoControl = new DaoTaoController();
            var result = daoTaoControl._Create(dt) as RedirectToRouteResult;

            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["action"]);

            daoTaoControl.Delete(id);
        }
예제 #3
0
        public void TestEditDaoTao()
        {
            DaoTao dt = new DaoTao(nameMonHoc, nameGiangVien, khoa, nganh);
            dt.ID = id;
            var daoTaoControl = new DaoTaoController();
            daoTaoControl._Create(dt);
            var result = daoTaoControl.Edit(dt.ID) as ViewResult;
            var dTao = (DaoTao)result.ViewData.Model;

            Assert.AreEqual(nameMonHoc, dTao.tenMonHoc);

            daoTaoControl.Delete(id);
        }
예제 #4
0
        public ActionResult _Create(DaoTao dT)
        {
            if (ModelState.IsValid)
            {
                db.daoTaos.Add(dT);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(dT);
        }
예제 #5
0
 public ActionResult Edit(DaoTao daotao)
 {
     if (ModelState.IsValid)
     {
         db.Entry(daotao).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(daotao);
 }
예제 #6
0
        public void TestSearchDaoTao()
        {
            DaoTao dt = new DaoTao(nameMonHoc, nameGiangVien, khoa, nganh);
            dt.ID = id;
            var daoTaoControl = new DaoTaoController();
            daoTaoControl._Create(dt);

            var result = daoTaoControl.SearchDaoTao(nganh, khoa.ToString()) as ViewResult;
            Assert.NotNull(result);
            daoTaoControl.Delete(id);
        }