Example #1
0
 public bool Update(TbDeThi entity)
 {
     try
     {
         var dethi = db.TbDeThis.SingleOrDefault(x => x.MaDeThi == entity.MaDeThi);
         dethi.MaCD       = entity.MaCD;
         dethi.MaMT       = entity.MaMT;
         dethi.MaDT       = entity.MaDT;
         dethi.DuongDanDT = entity.DuongDanDT;
         dethi.TrangThai  = entity.TrangThai;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #2
0
 public ActionResult Edit(TbDeThi exam)
 {
     if (ModelState.IsValid)
     {
         var dao    = new ExamDao();
         var result = dao.Update(exam);
         if (result)
         {
             SetAlert("Sửa đề thi thành công", "success");
             return(RedirectToAction("Index", "Exam"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật không thành công");
         }
     }
     return(View("Index"));
 }
Example #3
0
        public ActionResult Create(TbDeThi exam)
        {
            var dao = new ExamDao();
            var id  = dao.Insert(exam);

            if (id > 0)
            {
                SetAlert("Thêm đề thi mới thành công", "success");
                return(RedirectToAction("Index", "Exam"));
            }
            else
            {
                ModelState.AddModelError("", "Thêm mới không thành công");
            }

            SetViewBagLevel();
            SetViewBagObject();
            SetViewBagDt();
            return(View("Index"));
        }
Example #4
0
 public int Insert(TbDeThi entity)
 {
     db.TbDeThis.Add(entity);
     db.SaveChanges();
     return(entity.MaDeThi);
 }