コード例 #1
0
        public JsonResult Create(QuestionCreateForView model)
        {
            var modelNew = Mapper.Map <Question>(model);
            var isSaved  = _questionBll.Add(modelNew);

            model = new QuestionCreateForView();
            if (isSaved)
            {
                ViewBag.SMsg = "Saved Successfully";
            }



            List <Organization> olist = _organizationBll.GetAll();

            ViewBag.QuestionOrganizationList = new SelectList(olist, "Id", "Name", model.OrganizationId);    //If I not Write OrganizationId It also work Bcz Model Also contain OrganizationId
            //var courseId = course.Id;
            List <Course> clist = _courseBll.GetAll();

            ViewBag.QuestionCourseList = new SelectList(clist, "Id", "Name", model.CourseId);
            List <Exam> elist = _examBll.GetAll();

            ViewBag.QuestionExamList          = new SelectList(elist, "Id", "Topic", model.ExamId);
            model.QuestionTypeSelectListItems = _questionTypeBll.GetAll().Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(), Text = c.QuestionTypes
            });
            model.WriteQuestion = "";

            var jsonData = "success";

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult QuestionAdd(Question question)
        {
            if (question.Id != 0)
            {
                _questionBLL.Update(question);
            }
            else
            {
                _questionBLL.Add(question);
            }

            return(RedirectToAction("QuestionsList"));
        }