コード例 #1
0
        public ActionResult AddParticipantToTrial(AddParticipantToTrialViewModel m)
        {
            var trialParticipants = _db.Trial_Participant.Where(tp => tp.Trial_Id == m.TrialId && tp.Participant_Id == m.ParticipantId);

            if (trialParticipants.Count() == 0)
            {
                PX_Model.Trial_Participant trialParticipant = new PX_Model.Trial_Participant();

                trialParticipant.Trial_Id = m.TrialId;
                trialParticipant.Participant_Id = m.ParticipantId;

                _db.Trial_Participant.Add(trialParticipant);
                _db.SaveChanges();

                return View("Index");
            }
            else
            {
                ModelState.AddModelError("Add", "Participant is already in this trial!");
            }

            m.Trials = _db.Trials.OrderBy(t => t.Name).ToArray();
            m.Participants = _db.Participants.OrderBy(p => p.Person.First_Name).ToArray();

            return View(m);
        }
コード例 #2
0
        public ActionResult AddParticipantToTrial()
        {
            var m = new AddParticipantToTrialViewModel();

            m.Trials = _db.Trials.OrderBy(t => t.Name).ToArray();
            m.Participants = _db.Participants.OrderBy(p => p.Person.First_Name).ToArray();

            return View(m);
        }
コード例 #3
0
        public ActionResult AddParticipantToTrial(AddParticipantToTrialViewModel m)
        {
            //Get the trial participant associated with this trial
            var trialParticipants = _db.Trial_Participant.Where(tp => tp.Trial_Id == m.TrialId && tp.Participant_Id == m.ParticipantId);
            
            //If there are not trial participant associated
            if (trialParticipants.Count() == 0)
            {
                //Create trial participant
                PX_Model.Trial_Participant trialParticipant = new PX_Model.Trial_Participant();

                trialParticipant.Trial_Id = m.TrialId;
                trialParticipant.Participant_Id = m.ParticipantId;

                //Add trial participant
                _db.Trial_Participant.Add(trialParticipant);
                _db.SaveChanges();

                //Redirect to admin dashboard
                return View("Index");
            }
            else
            {
                //If there is already a trial participant object
                ModelState.AddModelError("Add", "Participant is already in this trial!");
            }

            //If there was an error, get the trial and participant lists and show the form again
            m.Trials = _db.Trials.OrderBy(t => t.Name).ToArray();
            m.Participants = _db.Participants.OrderBy(p => p.Person.First_Name).ToArray();

            return View(m);
        }
コード例 #4
0
        //Show the form for adding participant to database
        public ActionResult AddParticipantToTrial()
        {
            var m = new AddParticipantToTrialViewModel();

            //Get all trials and participant from the database
            m.Trials = _db.Trials.OrderBy(t => t.Name).ToArray();
            m.Participants = _db.Participants.OrderBy(p => p.Person.First_Name).ToArray();

            //Pass them on to the view
            return View(m);
        }