public ActionResult CreateTrial(CreateTrialViewModel m) { //If input is valid if (ModelState.IsValid) { //Create a trial var trial = new PX_Model.Trial(); trial.Name = m.Name; trial.Description = m.Description; trial.Start_Date = m.StartDate; trial.End_Date = m.EndDate; trial.Hypothesis = m.Hypothesis; trial.Outcome = m.Outcome; trial.Objectives = m.Objective; trial.TermsAndConditions = m.TermsAndConditions; trial.HasBeenRandomised = false; //Push the trial to the database _db.Trials.Add(trial); _db.SaveChanges(); //Go to the dashboard return View("Index"); } //If there was an error, redisplay the form with the errors return View(m); }
public ActionResult CreateTrial(CreateTrialViewModel m) { if (ModelState.IsValid) { var trial = new PX_Model.Trial(); trial.Name = m.Name; trial.Description = m.Description; trial.Start_Date = m.StartDate; trial.End_Date = m.EndDate; trial.Hypothesis = m.Hypothesis; trial.Outcome = m.Outcome; trial.Objectives = m.Objective; _db.Trials.Add(trial); _db.SaveChanges(); return View("Index"); } return View(m); }