示例#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);
        }
        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);
        }
        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);
 }
        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);
        }