public PrivateInvite Create(int pledgeCampaignId, string emailAddress, string recipientName, string token) { var values = new Dictionary<string, object> { {"Pledge_Campaign_ID", pledgeCampaignId}, {"Email_Address", emailAddress}, {"Recipient_Name", recipientName} }; try { var privateInviteId = _ministryPlatformService.CreateRecord(_tripInvitationsPageId, values, token, true); var record = _ministryPlatformService.GetRecordDict(_tripInvitationsPageId, privateInviteId, token, false); var invite = new PrivateInvite(); invite.EmailAddress = record.ToString("Email_Address"); invite.InvitationGuid = record.ToString("Invitation_GUID"); invite.InvitationUsed = record.ToBool("Invitation_Used"); invite.PledgeCampaignId = record.ToInt("Pledge_Campaign_ID"); invite.PledgeCampaignIdText = record.ToString("Pledge_Campaign_ID_Text"); invite.PrivateInvitationId = record.ToInt("Private_Invitation_ID"); invite.RecipientName = record.ToString("Recipient_Name"); return invite; } catch (Exception e) { throw new ApplicationException(string.Format("Create Private Invite failed. Pledge Campaign Id: {0}", pledgeCampaignId), e); } }
private Communication PrivateInviteCommunication(PrivateInvite invite) { var templateId = _configurationWrapper.GetConfigIntValue("PrivateInviteTemplate"); var template = _communicationService.GetTemplate(templateId); var fromContact = _contactService.GetContactById(_configurationWrapper.GetConfigIntValue("DefaultContactEmailId")); var mergeData = SetMergeData(invite.PledgeCampaignIdText, invite.PledgeCampaignId, invite.InvitationGuid, invite.RecipientName); return new Communication { AuthorUserId = 5, DomainId = 1, EmailBody = template.Body, EmailSubject = template.Subject, FromContact = new Contact {ContactId = fromContact.Contact_ID, EmailAddress = fromContact.Email_Address}, ReplyToContact = new Contact { ContactId = fromContact.Contact_ID, EmailAddress = fromContact.Email_Address }, ToContacts = new List<Contact> {new Contact{ContactId = fromContact.Contact_ID, EmailAddress = invite.EmailAddress}}, MergeData = mergeData }; }