public ActionResult EditTrial(EditTrialViewModel m)
        {
            var trial = _db.Trials.FirstOrDefault(t => t.Id == m.Id);

            if (trial != null)
            {
                trial.Name = m.Name;
                trial.Description = m.Description;
                trial.Start_Date = m.StartDate;
                trial.End_Date = m.EndDate;
                trial.Objectives = m.Objective;
                trial.Hypothesis = m.Hypothesis;
                trial.Outcome = m.Outcome;

                _db.SaveChanges();
            }

            return View("Index");
        }
        public ActionResult EditTrial(int id)
        {
            var trial = _db.Trials.FirstOrDefault(t => t.Id == id);

            if (trial != null)
            {
                var trialModel = new EditTrialViewModel();

                trialModel.Id = id;
                trialModel.Name = trial.Name;
                trialModel.Description = trial.Description;
                trialModel.StartDate = trial.Start_Date;
                trialModel.EndDate = trial.End_Date;
                trialModel.Objective = trial.Objectives;
                trialModel.Hypothesis = trial.Hypothesis;
                trialModel.Outcome = trial.Outcome;

                return View(trialModel);
            }

            return View("Index");
        }
        public ActionResult EditTrial(EditTrialViewModel m)
        {
            var trial = _db.Trials.FirstOrDefault(t => t.Id == m.Id);

            if (trial == null)
            {
                ModelState.AddModelError("Edit", "Trial was not found!");
            }

            if (ModelState.IsValid)
            {
                trial.Name = m.Name;
                trial.Description = m.Description;
                trial.Start_Date = m.StartDate;
                trial.End_Date = m.EndDate;
                trial.Objectives = m.Objective;
                trial.Hypothesis = m.Hypothesis;
                trial.Outcome = m.Outcome;

                _db.SaveChanges();
                return View("Index");
            }

            return View(m);
        }
        //Show form to edit trial
        public ActionResult EditTrial(int id)
        {
            //Get the trial we're editing
            var trial = _db.Trials.FirstOrDefault(t => t.Id == id);

            //If trial is in the database
            if (trial != null)
            {
                //Create a model to store the trial
                var trialModel = new EditTrialViewModel();

                trialModel.Id = id;
                trialModel.Name = trial.Name;
                trialModel.Description = trial.Description;
                trialModel.StartDate = trial.Start_Date;
                trialModel.EndDate = trial.End_Date;
                trialModel.Objective = trial.Objectives;
                trialModel.Hypothesis = trial.Hypothesis;
                trialModel.Outcome = trial.Outcome;
                trialModel.TermsAndConditions = trial.TermsAndConditions;

                //Send the trial data to the view
                return View(trialModel);
            }

            //If there was an error, go to index and show the error
            return View("Index");
        }
        public ActionResult EditTrial(EditTrialViewModel m)
        {
            //Get the trial from database
            var trial = _db.Trials.FirstOrDefault(t => t.Id == m.Id);

            //If trial is in the database
            if (trial != null)
            {
                //Save the user input in the trial object
                trial.Name = m.Name;
                trial.Description = m.Description;
                trial.Start_Date = m.StartDate;
                trial.End_Date = m.EndDate;
                trial.Objectives = m.Objective;
                trial.Hypothesis = m.Hypothesis;
                trial.Outcome = m.Outcome;
                trial.TermsAndConditions = m.TermsAndConditions;

                //Save the changes we made in trial object in our dataabase
                _db.SaveChanges();
            }

            //Return to the admin dashboard page
            return View("Index");
        }