Agribusiness.Web.Controllers.AttendeeController.UpdateAllRegistrations C# (CSharp) Method

UpdateAllRegistrations() private method

private UpdateAllRegistrations ( int id ) : System.Web.Mvc.ActionResult
id int
return System.Web.Mvc.ActionResult
        public ActionResult UpdateAllRegistrations(int id)
        {
            var seminar = _seminarRespository.GetNullableById(id);

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

            // make the remote call
            var result = _registrationService.RefreshAllRegistration(seminar.RegistrationId.Value);

            // load all of the seminar people
            var seminarPeople = seminar.SeminarPeople;

            foreach (var sp in seminarPeople)
            {
                var reg = result.Where(a => a.ReferenceId == sp.ReferenceId).FirstOrDefault();

                if (reg != null)
                {
                    sp.TransactionId = reg.TransactionId;
                    sp.Paid = reg.Paid;

                    // remove from the payment reminder mailing lists
                    if (sp.Paid)
                    {
                        _notificationService.RemoveFromMailingList(sp.Seminar, sp.Person, MailingLists.PaymentReminder);
                        _notificationService.RemoveFromMailingList(sp.Seminar, sp.Person, MailingLists.Registered);
                        _notificationService.AddToMailingList(sp.Seminar, sp.Person, MailingLists.Attending);
                    }

                    _seminarPersonRepository.EnsurePersistent(sp);
                }
            }

            Message = "Registration status' for all attendees have been updated.";
            return this.RedirectToAction(a => a.Index(id));
        }