public ActionResult AddPerson(int id, int seminarPersonId) { var session = _sessionRepository.GetNullableById(id); var seminarPerson = _seminarPersonRepository.GetNullableById(seminarPersonId); if (session == null) { Message = string.Format(Messages.NotFound, "session", id); return(this.RedirectToAction <SeminarController>(a => a.Index())); } if (seminarPerson == null) { Message = string.Format(Messages.NotFound, "seminar person", seminarPersonId); return(this.RedirectToAction <SeminarController>(a => a.Index())); } if (session.SessionPeople.Contains(seminarPerson)) { ModelState.AddModelError("Person", "Person already exists in the session."); } if (ModelState.IsValid) { session.SessionPeople.Add(seminarPerson); _sessionRepository.EnsurePersistent(session); Message = string.Format(Messages.Saved, "Session person"); return(this.RedirectToAction <SessionController>(a => a.Edit(id, session.Seminar.Id))); } var viewModel = SessionPersonViewModel.Create(Repository, session, seminarPerson); return(View(viewModel)); }
public ActionResult AddPerson(int id) { var session = _sessionRepository.GetNullableById(id); if (session == null) { Message = string.Format(Messages.NotFound, "session", id); return(this.RedirectToAction <SeminarController>(a => a.Index())); } var viewModel = SessionPersonViewModel.Create(Repository, session); return(View(viewModel)); }