public ActionResult Create(StudentCreateModel model) { if (!ModelState.IsValid) { return View(model); } var student = new Student(model.LastName, model.Forenames, model.EnrolmentDate.Value); Context.Students.Add(student); Context.SaveChanges(); var detailsModel = Mapper.Map<StudentDetailsModel>(student); return View("details", detailsModel); }
public ActionResult Create() { var model = new StudentCreateModel(); return View(model); }
private ActionResult RedirectToCreateWithValidation(StudentCreateModel model) { return View("create", new StudentCreateModel { Forenames = model.Forenames, LastName = model.LastName, EnrolmentDate = model.EnrolmentDate, ValidationRequired = model.ValidationRequired }); }