Ejemplo n.º 1
0
        // GET: /Participant/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Participant participant = db.Participants.Find(id);
            if (participant == null)
            {
                return HttpNotFound();
            }

            var model = new ParticipantEditViewModel();
            model.StudyMeetingId = participant.StudyMeeting.Id;
            model.Participant = participant;

            return View(model);
        }
Ejemplo n.º 2
0
        public IHttpActionResult PostParticipant(ParticipantEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var meeting = db.StudyMeetings.Find(model.StudyMeetingId);
            if (meeting == null)
            {
                return BadRequest(string.Format("Not found study meeting.(StudyMeetingId={0})", model.StudyMeetingId));
            }

            meeting.Participants.Add(model.Participant);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = model.Participant.Id }, model);
        }
Ejemplo n.º 3
0
 public ActionResult Edit(Participant participant, int studyMeetingId)
 {
     if (ModelState.IsValid)
     {
         db.Entry(participant).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Add", new { id = studyMeetingId });
     }
     var model = new ParticipantEditViewModel();
     model.StudyMeetingId = studyMeetingId;
     model.Participant = participant;
     return View(model);
 }