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)); }
public JsonResult CreateExamTable() { var dataList = _examBll.GetAll(); var jsonData = dataList.Select(x => new Exam() { Id = x.Id, CourseId = x.CourseId, ExamCode = x.ExamCode }); return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public JsonResult GetExamByCourseId(int courseId) { var model = new ExamEntryForView(); var datalist = _examBll.GetAll().Where(c => c.CourseId == courseId).ToList(); var jsonData = datalist.Select(c => new { c.Id, c.Topic }); return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(ExamEntryForView model) { var exam = Mapper.Map <Exam>(model); var examall = _examEntryBll.GetAll(); var Isave = false; for (int i = 0; i < examall.Count; i++) { if ((model.ExamCode == examall[i].ExamCode)) { Isave = true; } } if (Isave == true) { ViewBag.EMsg = "Duplicate"; } else { bool isAdded = _examEntryBll.Add(exam); if (isAdded) { ViewBag.SMsg = "Save Is Successfully"; model = new ExamEntryForView(); } else { ViewBag.EMsg = "Save Is UnSuccessfully"; } } model.OrganizationSelectListItems = _organizationBll.GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }); model.CourseSelectListItems = _courseBll.GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }); model.ExamTypeList = _examTypeBll.GetAll() .Select(c => new SelectListItem() { Value = c.Examtype.ToString(), Text = c.ExamtypeName }).ToList(); return(View(model)); }