private void btnSave_Click(object sender, EventArgs e) { try { aExam.ExamMaxDuration = TimeSpan.Parse(mtxbDurationT.Text); aExam.MaxAllowedAttemptsPerPerson = Convert.ToInt32(txbMaxAttemps.Text); aExam.ExamStartDate = Convert.ToDateTime(dtpStartDate.Text); aExam.ExamStartTime = TimeSpan.Parse(mtxbStrTime.Text); aExam.ExamEndDate = Convert.ToDateTime(dtpEndDate.Text); aExam.ExamEndTime = TimeSpan.Parse(mtxbEndTime.Text); if (txbExamID.Text == "") { ExamManager.Add(aExam); } else { aExam.ExamID = Convert.ToInt32(txbExamID.Text); ExamManager.Update(aExam); } PopulateData(aExam.ExaminerID); Clear(this.Controls); MessageBox.Show("Submit Successfully!"); } catch (Exception ex) { MessageBox.Show("Error when adding the exam data: " + ex.Message, ex.GetType().ToString()); } }
public IActionResult Create([Bind("Id,Date,StartTime,EndTime,CourseId,TeacherId")] ExamViewModel examViewModel) { if (ModelState.IsValid) { Exam exam = MapToExam(examViewModel); _examManager.Add(exam); return(RedirectToAction(nameof(Index), new { message = "create" })); } return(View()); }
public void AddExam_Test() { _manager.Add(EXAM); IList <Exam> exams = _manager.GetAll().ToList(); Assert.Equal(1, exams.Count); Exam exam = exams.First(); Assert.Equal("ASP .NET", exam.Course.CourseName); }
//public JsonResult GetStudentById(int CourseId) //{ // var model = db.Exams.Where(x => x.CourseId == CourseId).SingleOrDefault(); // string value = string.Empty; // value = JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings // { // ReferenceLoopHandling = ReferenceLoopHandling.Ignore // }); // return Json(value, JsonRequestBehavior.AllowGet); //} public ActionResult CreateExam(List <CreateExamVM> Exams) { var exams = AutoMapper.Mapper.Map <List <Exam> >(Exams); bool IsSaved = examManager.Add(exams); if (IsSaved) { return(Json(true)); } else { return(Json(false)); } }
public ActionResult Entry(ExamEntryVm model) { if (ModelState.IsValid) { var exam = Mapper.Map <Exam>(model); bool isAdded = _examManager.Add(exam); if (isAdded) { return(RedirectToAction("Index")); } } return(View()); }
public ActionResult Entry(ExamCreateVm entity) { if (ModelState.IsValid) { var exam = Mapper.Map <Exam>(entity); var exams = _examManager.GetAllExams(); if (exams.FirstOrDefault(x => x.Code == exam.Code) != null) { ViewBag.Message = "Exist"; entity.ExamTypeSelectListItems = GetAllExamTypesSLI(); entity.OrganizationSelectListItems = GetAllOrganizationSlI(); return(View(entity)); } else { bool isAdded = _examManager.Add(exam); if (isAdded) { ModelState.Clear(); ViewBag.Message = "Saved"; var examSerial = _examManager.ExamCounter(); var model = new ExamCreateVm() { ExamTypeSelectListItems = GetAllExamTypesSLI(), OrganizationSelectListItems = GetAllOrganizationSlI(), Serial = ++examSerial }; return(View(model)); } } } ModelState.AddModelError("", "An Unknown Error Occured!"); entity.ExamTypeSelectListItems = GetAllExamTypesSLI(); entity.OrganizationSelectListItems = GetAllOrganizationSlI(); return(View(entity)); }
public ExamModel Add([FromBody] ExamModel examModel) { var exam = ExamManager.Add(Mapper.AutoMap <ExamModel, Exam>(examModel)); return(Mapper.Map(exam)); }