public JsonResult AddSubject(Subject subject)
        {
            if (subject == null)
            {
                return(Json(new { Message = "Error", HasError = true }, JsonRequestBehavior.AllowGet));
            }

            var dao     = new SubjectDAO();
            var message = dao.AddSubject(subject);

            return(Json(new { Message = message }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 // GET: Admin/Users/Create
 public ActionResult Create(Subject sub)
 {
     if (ModelState.IsValid)
     {
         var dao = new SubjectDAO();
         sub.CreateDate   = DateTime.Now;
         sub.SkipSwap     = false;
         sub.clogic       = false;
         sub.AnswerOption = false;
         sub.NoOfAnswers  = 4;
         sub.roundToZero  = false;
         sub.skipMinus    = false;
         int id = dao.AddSubject(sub);
         if (id != 0)
         {
             return(RedirectToAction("Index", "Subject"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm môn thi thất bại");
         }
     }
     return(View("Create"));
 }