Esempio n. 1
0
 public ActionResult AddCategory(Models.QuestionCategory category)
 {
     category.ModifiedBy = int.Parse(Session["Name"].ToString());
     category.CreatedBy  = int.Parse(Session["Name"].ToString());
     try
     {
         if (ModelState.IsValid)
         {
             if (category.CategoryID == 0)
             {
                 if (questionCategorySevice.AddCategoryQuestion(category) > 0)
                 {
                     Success = "Insert question category successfully!";
                     return(RedirectToAction("AddCategory", "QuestionCategory"));
                 }
             }
             else
             {
                 category.ModifiedBy = int.Parse(Session["Name"].ToString());
                 if (questionCategorySevice.UpdateCategoryQuestion(category) > 0)
                 {
                     Success = "Update exam paper successfully!";
                     return(RedirectToAction("AddCategory", "QuestionCategory"));
                 }
             }
         }
         Success = "Update exam paper successfully!";
         return(RedirectToAction("AddCategory", "QuestionCategory"));
     }
     catch (Exception exception)
     {
         Failure = exception.Message;
         return(View(category));
     }
 }
Esempio n. 2
0
 public JsonResult AddCategory(Models.QuestionCategory category)
 {
     category.ModifiedBy = int.Parse(Session["Name"].ToString());
     category.CreatedBy  = int.Parse(Session["Name"].ToString());
     // Default is true when create in CreateQuesiton View
     category.IsActive = true;
     return(Json(questionCategorySevice.AddCategoryQuestion(category), JsonRequestBehavior.AllowGet));
 }