public ActionResult Entry(ExamEntryVm examEntryVm) { examEntryVm.Duration = TimeSpan.FromHours(Convert.ToDouble(examEntryVm.Hour)) + TimeSpan.FromMinutes(Convert.ToDouble(examEntryVm.Minute)); bool courseCheckByName = examManager.CheckExamByCode(examEntryVm.ExamCode); examEntryVm.OrganizationSelectListItems = GetOrganizationListItem(); examEntryVm.CourseSelectListItems = GetCourseListItem(); examEntryVm.ExamTypeSelectListItems = GetExamTypeListItem(); foreach (var examType in examEntryVm.ExamTypeSelectListItems) { if (examType.Value == examEntryVm.ExamTypeId.ToString()) { examEntryVm.ExamType = examType.Text; } } if (courseCheckByName) { ModelState.AddModelError("ExamCode", "Exam Already Registered!"); } var exam = Mapper.Map <Exams>(examEntryVm); if (ModelState.IsValid) { bool isSaved = examManager.AddExam(exam); if (isSaved) { return(RedirectToAction("QuestionAnswerEntry")); } } return(View(examEntryVm)); }