Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public ActionResult _Create(DaoTao dT)
        {
            if (ModelState.IsValid)
            {
                db.daoTaos.Add(dT);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(dT);
        }
Esempio n. 5
0
 public ActionResult Edit(DaoTao daotao)
 {
     if (ModelState.IsValid)
     {
         db.Entry(daotao).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(daotao);
 }
Esempio n. 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);
        }