示例#1
0
        private void SendEventReminderEmail(Models.Crossroads.Events.Event evt, Participant participant, MpEvent childcareEvent, IList <Participant> children, string token)
        {
            try
            {
                var mergeData = new Dictionary <string, object>
                {
                    { "Nickname", participant.Nickname },
                    { "Event_Title", evt.name },
                    { "Event_Start_Date", evt.StartDate.ToShortDateString() },
                    { "Event_Start_Time", evt.StartDate.ToShortTimeString() },
                    { "cmsChildcareEventReminder", string.Empty },
                    { "Childcare_Children", string.Empty },
                    { "Childcare_Contact", string.Empty } // Set these three parameters no matter what...
                };

                if (children.Any())
                {
                    // determine if any of the children are related to the participant
                    var mine = MyChildrenParticipants(participant.ContactId, children, token);
                    // build the HTML for the [Childcare] data
                    if (mine.Any())
                    {
                        mergeData["cmsChildcareEventReminder"] = _contentBlockService["cmsChildcareEventReminder"].Content;
                        var childcareString = ChildcareData(mine);
                        mergeData["Childcare_Children"] = childcareString;
                        mergeData["Childcare_Contact"]  = new HtmlElement("span", "If you need to cancel, please email " + childcareEvent.PrimaryContact.EmailAddress).Build();
                    }
                }
                var defaultContact = _contactService.GetContactById(AppSetting("DefaultContactEmailId"));
                var comm           = _communicationService.GetTemplateAsCommunication(
                    AppSetting("EventReminderTemplateId"),
                    defaultContact.Contact_ID,
                    defaultContact.Email_Address,
                    evt.PrimaryContactId,
                    evt.PrimaryContactEmailAddress,
                    participant.ContactId,
                    participant.EmailAddress,
                    mergeData);
                _communicationService.SendMessage(comm);
            }
            catch (Exception ex)
            {
                _logger.Error("Error sending Event Reminder email.", ex);
            }
        }
示例#2
0
        private MpCommunication CreateJourneyInvitation(EmailCommunicationDTO communication, Participant particpant)
        {
            var template    = _communicationService.GetTemplate(communication.TemplateId);
            var fromContact = _contactService.GetContactById(_configurationWrapper.GetConfigIntValue("DefaultContactEmailId"));
            var replyTo     = _contactService.GetContactById(particpant.ContactId);
            var mergeData   = SetupMergeData(particpant.PreferredName, communication.groupId.Value);

            return(new MpCommunication
            {
                AuthorUserId = 5,
                DomainId = 1,
                EmailBody = template.Body,
                EmailSubject = template.Subject,
                FromContact = new MpContact {
                    ContactId = _defaultContactEmailId, EmailAddress = fromContact.Email_Address
                },
                ReplyToContact = new MpContact {
                    ContactId = _defaultContactEmailId, EmailAddress = replyTo.Email_Address
                },
                ToContacts = new List <MpContact> {
                    new MpContact {
                        ContactId = fromContact.Contact_ID, EmailAddress = communication.emailAddress
                    }
                },
                MergeData = mergeData
            });
        }
示例#3
0
        public GroupDTO getGroupDetails(int groupId, int contactId, Participant participant, string authUserToken)
        {
            int     participantId = participant.ParticipantId;
            MpGroup g             = _mpGroupService.getGroupDetails(groupId);

            var signupRelations = _mpGroupService.GetGroupSignupRelations(g.GroupType);

            var currRelationships = _contactRelationshipService.GetMyCurrentRelationships(contactId, authUserToken);

            var events = _mpGroupService.getAllEventsForGroup(groupId);

            MpContactRelationship[] familyToReturn = null;

            if (currRelationships != null)
            {
                familyToReturn = currRelationships.Where(
                    c => signupRelations.Select(s => s.RelationshipId).Contains(c.Relationship_Id)).ToArray();
            }

            var apiToken        = _apiUserService.GetToken();
            var configuration   = MpObjectAttributeConfigurationFactory.Group();
            var attributesTypes = _objectAttributeService.GetObjectAttributes(apiToken, groupId, configuration);

            var detail = new GroupDTO();

            {
                detail.ContactId            = g.ContactId;
                detail.CongregationId       = g.CongregationId;
                detail.KidsWelcome          = g.KidsWelcome;
                detail.GroupName            = g.Name;
                detail.GroupDescription     = g.GroupDescription;
                detail.GroupId              = g.GroupId;
                detail.GroupFullInd         = g.Full;
                detail.WaitListInd          = g.WaitList;
                detail.ChildCareAvailable   = g.ChildCareAvailable;
                detail.WaitListGroupId      = g.WaitListGroupId;
                detail.OnlineRsvpMinimumAge = g.MinimumAge;
                detail.MeetingFrequencyID   = g.MeetingFrequencyID;
                detail.AvailableOnline      = g.AvailableOnline;
                detail.MeetingTime          = g.MeetingTime;
                detail.MeetingDayId         = g.MeetingDayId;
                detail.Address              = Mapper.Map <MpAddress, AddressDTO>(g.Address);
                detail.StartDate            = g.StartDate;
                detail.Participants         = (g.Participants.Count > 0) ? g.Participants.Select(p => Mapper.Map <MpGroupParticipant, GroupParticipantDTO>(p)).ToList() : null;

                if (events != null)
                {
                    detail.Events = events.Select(Mapper.Map <MpEvent, Event>).ToList();
                }
                //the first instance of family must always be the logged in user
                var fam = new SignUpFamilyMembers
                {
                    EmailAddress    = participant.EmailAddress,
                    PreferredName   = participant.PreferredName,
                    UserInGroup     = _mpGroupService.checkIfUserInGroup(participantId, g.Participants),
                    ParticpantId    = participantId,
                    ChildCareNeeded = false
                };
                detail.SignUpFamilyMembers = new List <SignUpFamilyMembers> {
                    fam
                };

                if (familyToReturn != null)
                {
                    foreach (var f in familyToReturn)
                    {
                        var fm = new SignUpFamilyMembers
                        {
                            EmailAddress  = f.Email_Address,
                            PreferredName = f.Preferred_Name,
                            UserInGroup   = _mpGroupService.checkIfUserInGroup(f.Participant_Id, g.Participants),
                            ParticpantId  = f.Participant_Id,
                        };
                        detail.SignUpFamilyMembers.Add(fm);
                    }
                }

                detail.AttributeTypes   = attributesTypes.MultiSelect;
                detail.SingleAttributes = attributesTypes.SingleSelect;
            }

            return(detail);
        }