public ActionResult Create(AddServiceRequest newItem) { var sr = new ServiceRequestBase(); ProgramManager pm = new ProgramManager(); StudentManager sm = new StudentManager(); if (ModelState.IsValid) { //Student Number does not exisit in the database if (sm.getStudentByStudentNumber(newItem.studentNumber) == 0) { ViewBag.StudentInvalidErrorMessage = "*Student Number does not exisit in the system"; var addForm = Mapper.Map <ServiceRequestAddForm>(newItem); addForm.program = new SelectList(pm.getAllPrograms(), "Id", "programCode"); return(View(addForm)); } var addetItem = m.AddNewServiceRequest(newItem); if (addetItem == null) { return(RedirectToAction("index")); } else { return(RedirectToAction("confirm")); } } else { var addForm = Mapper.Map <ServiceRequestAddForm>(newItem); addForm.program = new SelectList(pm.getAllPrograms(), "Id", "programCode"); return(View(addForm)); } }
public ActionResult Create(AddServiceRequest newItem) { var sr = new ServiceRequestBase(); ProgramManager pm = new ProgramManager(); StudentManager sm = new StudentManager(); if (ModelState.IsValid) { //Student Number does not exisit in the database if ( sm.getStudentByStudentNumber(newItem.studentNumber) == 0) { ViewBag.StudentInvalidErrorMessage = "*Student Number does not exisit in the system"; var addForm = Mapper.Map<ServiceRequestAddForm>(newItem); addForm.program = new SelectList(pm.getAllPrograms(), "Id", "programCode"); return View(addForm); } var addetItem = m.AddNewServiceRequest(newItem); if (addetItem == null) { return RedirectToAction("index"); } else { return RedirectToAction("confirm"); } } else { var addForm = Mapper.Map<ServiceRequestAddForm>(newItem); addForm.program = new SelectList(pm.getAllPrograms(), "Id", "programCode"); return View(addForm); } }