public ActionResult AddConfirm(int id, int personId)
        {
            var seminar = _seminarRespository.GetNullableById(id);

            if (seminar == null)
            {
                Message = string.Format(Messages.NotFound, "Seminar", id);
                return(this.RedirectToAction <SeminarController>(a => a.Index()));
            }

            var person = _personRepository.GetNullableById(personId);

            if (person == null)
            {
                Message = string.Format(Messages.NotFound, "person", personId);
                return(this.RedirectToAction(a => a.Add(id)));
            }

            var seminarPerson = person.GetLatestRegistration(Site);

            if (seminarPerson != null && seminarPerson.Seminar == seminar)
            {
                Message = string.Format("{0} is already part of this seminar and cannot be added.", person.FullName);
                return(this.RedirectToAction(a => a.Add(id)));
            }

            var viewModel = AddConfirmViewModel.Create(Repository, _firmService, seminar, person, seminarPerson, seminarPerson != null ? seminarPerson.Firm : null);

            return(View(viewModel));
        }
        public ActionResult AddConfirm(int id, int personId, SeminarPerson seminarPerson, Firm firm)
        {
            var seminar = _seminarRespository.GetNullableById(id);

            if (seminar == null)
            {
                Message = string.Format(Messages.NotFound, "Seminar", id);
                return(this.RedirectToAction <SeminarController>(a => a.Index()));
            }

            var person = _personRepository.GetNullableById(personId);

            if (person == null)
            {
                Message = string.Format(Messages.NotFound, "person", personId);
                return(this.RedirectToAction(a => a.Add(id)));
            }

            if (firm.Id > 0)
            {
                seminarPerson.Firm = _firmRepository.GetNullableById(firm.Id);
            }
            else if (firm.Id == 0)
            {
                seminarPerson.Firm = firm;
            }

            // fill in the values
            seminarPerson.Person  = person;
            seminarPerson.Seminar = seminar;

            ModelState.Clear();
            seminarPerson.TransferValidationMessagesTo(ModelState);

            if (seminarPerson.Firm != null)
            {
                seminarPerson.Firm.TransferValidationMessagesTo(ModelState);
            }

            if (ModelState.IsValid)
            {
                _seminarPersonRepository.EnsurePersistent(seminarPerson);
                Message = string.Format("{0} has been added to the {1} seminar.", person.FullName, seminar.Year);

                _notificationService.AddToMailingList(seminar, person, MailingLists.Registered);

                // add user to the reminder emails
                _notificationService.AddToMailingList(seminar, person, MailingLists.PaymentReminder);
                _notificationService.AddToMailingList(seminar, person, MailingLists.HotelReminder);

                if (string.IsNullOrWhiteSpace(person.Biography))
                {
                    _notificationService.AddToMailingList(seminar, person, MailingLists.BioReminder);
                }
                if (person.OriginalPicture == null)
                {
                    _notificationService.AddToMailingList(seminar, person, MailingLists.PhotoReminder);
                }

                return(this.RedirectToAction(a => a.Add(id)));
            }

            var viewModel = AddConfirmViewModel.Create(Repository, _firmService, seminar, person, seminarPerson, seminarPerson.Firm);

            return(View(viewModel));
        }