private int PreferredLaunchSite(Registration registration) { int preferredLaunchSiteId; if (registration.PreferredLaunchSite.Id == 0) { // use group connector var groupConnector = _groupConnectorService.GetGroupConnectorById(registration.GroupConnector.GroupConnectorId); preferredLaunchSiteId = groupConnector.PreferredLaunchSiteId; } else { // use preferred id preferredLaunchSiteId = registration.PreferredLaunchSite.Id; } return(preferredLaunchSiteId); }
public bool SendMail(Registration registration) { try { int templateId; int leaderTemplateId = 0; MpMyContact fromContact; MpMyContact replyContact; Dictionary <string, object> mergeData; if (registration.GetType() == typeof(CincinnatiRegistration)) { templateId = _configurationWrapper.GetConfigIntValue("GoVolunteerEmailTemplate"); var fromContactId = _configurationWrapper.GetConfigIntValue("GoVolunteerEmailFromContactId"); fromContact = _contactService.GetContactById(fromContactId); replyContact = fromContact; mergeData = SetupMergeData((CincinnatiRegistration)registration); } else { templateId = _configurationWrapper.GetConfigIntValue("GoLocalAnywhereEmailTemplate"); leaderTemplateId = _configurationWrapper.GetConfigIntValue("GoLocalAnywhereLeaderEmailTemplate"); var projectLeader = _groupConnectorService.GetGroupConnectorById(registration.GroupConnectorId); fromContact = _contactService.GetContactById(_configurationWrapper.GetConfigIntValue("GoLocalAnywhereFromContactId")); replyContact = _contactService.GetContactById(projectLeader.PrimaryRegistrationID); mergeData = SetupAnywhereMergeData((AnywhereRegistration)registration, projectLeader.Name); mergeData.Add("Project_Leader_Email_Address", replyContact.Email_Address); mergeData.Add("Project_ID", projectLeader.ProjectId); } var communication = _communicationService.GetTemplateAsCommunication(templateId, fromContact.Contact_ID, fromContact.Email_Address, replyContact.Contact_ID, replyContact.Email_Address, registration.Self.ContactId, registration.Self.EmailAddress, mergeData); var returnVal = _communicationService.SendMessage(communication); if (registration.SpouseParticipation && registration.Spouse != null && returnVal > 0) { var spouseTemplateId = _configurationWrapper.GetConfigIntValue("GoVolunteerEmailSpouseTemplate"); var spouseCommunication = _communicationService.GetTemplateAsCommunication(spouseTemplateId, fromContact.Contact_ID, fromContact.Email_Address, fromContact.Contact_ID, fromContact.Email_Address, registration.Spouse.ContactId, registration.Spouse.EmailAddress, mergeData); _communicationService.SendMessage(spouseCommunication); } if (leaderTemplateId != 0) { mergeData.Add("Anywhere_GO_Contact", fromContact.Email_Address); var leaderCommunication = _communicationService.GetTemplateAsCommunication(leaderTemplateId, fromContact.Contact_ID, fromContact.Email_Address, fromContact.Contact_ID, fromContact.Email_Address, replyContact.Contact_ID, replyContact.Email_Address, mergeData); _communicationService.SendMessage(leaderCommunication); } return(returnVal > 0); } catch (Exception e) { _logger.Error("Sending email failed"); return(false); } }