Пример #1
0
        // GET: /Participant/Add/5
        public ActionResult Add(int? id)
        {
            if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            StudyMeeting studyMeeting = db.StudyMeetings.Find(id);
            if (studyMeeting == null) return HttpNotFound();

            var model = new ParticipantAddViewModel
            {
                StudyMeeting = studyMeeting,
                Participants = studyMeeting.Participants.ToList(),
            };
            return View(model);
        }
Пример #2
0
        public ActionResult Add(int id, Participant participant)
        {
            StudyMeeting studyMeeting = db.StudyMeetings.Find(id);

            if (ModelState.IsValid)
            {
                studyMeeting.Participants.Add(participant);
                db.SaveChanges();
                return RedirectToAction("Add", new { Id = id });
            }

            var model = new ParticipantAddViewModel
            {
                StudyMeeting = studyMeeting,
                Participants = studyMeeting.Participants.ToList()
            };
            return View(model);
        }