public ActionResult Create() { // Create a form var form = new IncidentAddForm(); form.StudentId = new List <string>(); form.StudentName = new List <string>(); for (int i = 0; i < 20; i++) { form.StudentId.Add(""); form.StudentName.Add(""); } return(View(form)); }
public ActionResult Create(IncidentAdd newItem) { /* * if (!ModelState.IsValid) * { * return RedirectToAction("Create", AutoMapper.Mapper.Map<IncidentAddForm>(newItem)); * }*/ if (newItem.DocUpload != null) { if (newItem.DocUpload.ContentType != "application/pdf") { IncidentAddForm form = new IncidentAddForm(); form.StudentId = new List <string>(); form.StudentName = new List <string>(); form.campus = newItem.campus; form.coursecode = newItem.coursecode; form.description = newItem.description; form.IncidentDate = newItem.IncidentDate; form.InstructorName = newItem.InstructorName; form.isMinor = newItem.isMinor; form.program = newItem.program; form.StudentName = newItem.StudentName; form.StudentId = newItem.StudentId; return(View(form)); } } // Process the input var addedItem = m.IncidentAdd(newItem); if (addedItem == null) { return(RedirectToAction("Create", AutoMapper.Mapper.Map <IncidentAddForm>(newItem))); } else { return(RedirectToAction("Details", new { id = addedItem.Id })); } }