public ActionResult Index() { try { var seminar = SiteService.GetLatestSeminar(Site); if (seminar.RegistrationId.HasValue) { 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.FirstOrDefault(a => a.ReferenceId == sp.ReferenceId); 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); } } } } catch (Exception ex) { var client = new SmtpClient("smtp.ucdavis.edu"); var message = new MailMessage("*****@*****.**", "*****@*****.**"); message.Subject = "Error Syncing from Agribusiness"; message.Body = ex.Message; client.Send(message); } //if (ConfigurationManager.AppSettings["SyncCall"] == "true") //{ // // determine the address of the calling person. // var client = new SmtpClient("smtp.ucdavis.edu"); // var message = new MailMessage("*****@*****.**", "*****@*****.**"); // message.Subject = "sync call was made to agribusiness and completed"; // message.Body = Request.UserHostAddress ?? "No address"; // client.Send(message); //} return(View()); }
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))); }