Example #1
0
        public void SendTripIsFullMessage(int campaignId)
        {
            var campaign = GetTripCampaign(campaignId);

            if (!campaign.IsFull)
            {
                return;
            }
            var templateId              = _configurationWrapper.GetConfigIntValue("TripIsFullTemplateId");
            var fromReplyToContactId    = _configurationWrapper.GetConfigIntValue("TripIsFullFromContactId");
            var fromReplyToEmailAddress = _configurationWrapper.GetConfigValue("TripIsFullFromEmailAddress");

            var eventDeets = _mpEventService.GetEvent(campaign.EventId);

            var mergeData = new Dictionary <String, Object>
            {
                { "Pledge_Campaign", campaign.Name }
            };

            var communication = _communicationService.GetTemplateAsCommunication(templateId,
                                                                                 fromReplyToContactId,
                                                                                 fromReplyToEmailAddress,
                                                                                 fromReplyToContactId,
                                                                                 fromReplyToEmailAddress,
                                                                                 eventDeets.PrimaryContact.ContactId,
                                                                                 eventDeets.PrimaryContact.EmailAddress,
                                                                                 mergeData);

            _communicationService.SendMessage(communication);
        }
        public CheckScannerController(IConfigurationWrapper configuration,
                                      ICheckScannerService checkScannerService,
                                      IAuthenticationRepository authenticationService,
                                      ICommunicationRepository communicationService,
                                      ICryptoProvider cryptoProvider,
                                      IUserImpersonationService userImpersonationService,
                                      IMessageQueueFactory messageQueueFactory = null,
                                      IMessageFactory messageFactory           = null) : base(userImpersonationService)
        {
            _checkScannerService   = checkScannerService;
            _authenticationService = authenticationService;
            _communicationService  = communicationService;
            _cryptoProvider        = cryptoProvider;

            var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode");

            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName");
                // ReSharper disable once PossibleNullReferenceException
                _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
        }
Example #3
0
        // ReSharper disable once UnusedParameter.Local
        private void SendPrimaryContactReminderEmail(Models.Crossroads.Events.Event evt, string rooms, string token, string actionText)
        {
            try
            {
                var mergeData = new Dictionary <string, object>
                {
                    { "Event_ID", evt.EventId },
                    { "Event_Title", evt.name },
                    { "Event_Start_Date", evt.StartDate.ToShortDateString() },
                    { "Event_Start_Time", evt.StartDate.ToShortTimeString() },
                    { "Room_Name", rooms },
                    { "Base_Url", _configurationWrapper.GetConfigValue("BaseMPUrl") },
                    { "Action_Needed", actionText }
                };

                var defaultContact = _contactService.GetContactById(AppSetting("DefaultContactEmailId"));
                var comm           = _communicationService.GetTemplateAsCommunication(
                    AppSetting("EventPrimaryContactReminderTemplateId"),
                    defaultContact.Contact_ID,
                    defaultContact.Email_Address,
                    evt.PrimaryContactId,
                    evt.PrimaryContactEmailAddress,
                    evt.PrimaryContactId,
                    evt.PrimaryContactEmailAddress,
                    mergeData);
                _communicationService.SendMessage(comm);
            }
            catch (Exception ex)
            {
                _logger.Error("Error sending Event Reminder email.", ex);
            }
        }
Example #4
0
        public TwilioService(IConfigurationWrapper configurationWrapper)
        {
            var accountSid = configurationWrapper.GetConfigValue("TwilioAccountSid");
            var authToken  = configurationWrapper.GetEnvironmentVarAsString("TWILIO_AUTH_TOKEN");

            _fromPhoneNumber = configurationWrapper.GetConfigValue("TwilioFromPhoneNumber");
            _twilio          = new TwilioRestClient(accountSid, authToken);
        }
Example #5
0
        private void CreateNewUserSubscriptions(int contactRecordId, string token)
        {
            var newSubscription = new Dictionary <string, object>();

            newSubscription["Publication_ID"] = _configurationWrapper.GetConfigValue("KidsClubPublication");
            newSubscription["Unsubscribed"]   = false;
            _subscriptionsService.SetSubscriptions(newSubscription, contactRecordId, token);
            newSubscription["Publication_ID"] = _configurationWrapper.GetConfigValue("CrossroadsPublication");
            newSubscription["Unsubscribed"]   = false;
            _subscriptionsService.SetSubscriptions(newSubscription, contactRecordId, token);
        }
Example #6
0
        public Dictionary <string, object> SetMergeDataForChildcareReminder(MpContact toContact, DateTime threeDaysOut)
        {
            var person = _contactService.GetContactById(toContact.ContactId);
            var url    = _configurationWrapper.GetConfigValue("BaseUrl");

            return(new Dictionary <string, object>()
            {
                { "Nickname", person.Nickname },
                { "Childcare_Date", threeDaysOut.ToString("MM/dd/yyyy") },
                { "Childcare_Day", threeDaysOut.ToString("dddd, MMMM dd") },
                { "Base_URL", $"https://{url}" }
            });
        }
Example #7
0
        public List <MyCampDTO> GetMyCampInfo(string token)
        {
            var apiToken = _apiUserRepository.GetToken();
            var campType = _configurationWrapper.GetConfigValue("CampEventTypeName");

            var dashboardData = new List <MyCampDTO>();

            var loggedInContact = _contactRepository.GetMyProfile(token);
            var family          = _contactRepository.GetHouseholdFamilyMembers(loggedInContact.Household_ID);

            family.AddRange(_contactRepository.GetOtherHouseholdMembers(loggedInContact.Household_ID));

            // US8846: show camps for 60 days beyond the end date so that users can continue to
            // make payments even after the camp is completed.
            DateTime cutoffDate = DateTime.Today.AddDays(-60);

            var camps = _eventRepository.GetEvents(campType, apiToken);

            foreach (var camp in camps.Where(c => c.EventEndDate >= cutoffDate))
            {
                var campers = _eventRepository.EventParticipants(apiToken, camp.EventId).ToList();
                if (campers.Any())
                {
                    foreach (var member in family)
                    {
                        if (campers.Any(c => c.ContactId == member.ContactId))
                        {
                            var product        = _productRepository.GetProductForEvent(camp.EventId);
                            var invoiceDetails = _invoiceRepository.GetInvoiceDetailsForProductAndCamper(product.ProductId, member.ContactId);
                            PaymentDetailDTO paymentDetail;
                            paymentDetail = invoiceDetails.Value == null ? null : _paymentService.GetPaymentDetails(0, invoiceDetails.Value.InvoiceId, token);

                            dashboardData.Add(new MyCampDTO
                            {
                                CamperContactId         = member.ContactId,
                                CamperNickName          = member.Nickname ?? member.FirstName,
                                CamperLastName          = member.LastName,
                                CampName                = camp.EventTitle,
                                CampStartDate           = camp.EventStartDate,
                                CampEndDate             = camp.EventEndDate,
                                EventId                 = camp.EventId,
                                CampPrimaryContactEmail = _eventRepository.GetEvent(camp.EventId).PrimaryContact.EmailAddress,
                                CamperInvoice           = paymentDetail
                            });
                        }
                    }
                }
            }

            return(dashboardData);
        }
Example #8
0
        public void SendPaymentConfirmation(int paymentId, int eventId, string token)
        {
            var payment = _paymentRepository.GetPaymentById(paymentId);
            var mpEvent = _eventPRepository.GetEvent(eventId);
            var me      = _contactRepository.GetMyProfile(token);

            var templateIdResult = _eventPRepository.GetProductEmailTemplate(eventId);
            var templateId       = (templateIdResult.Status) ? templateIdResult.Value : _configWrapper.GetConfigIntValue("DefaultPaymentEmailTemplate");
            var mergeData        = new Dictionary <string, object>
            {
                { "Event_Title", mpEvent.EventTitle },
                { "Payment_Total", payment.PaymentTotal.ToString(".00") },
                { "Primary_Contact_Email", mpEvent.PrimaryContact.EmailAddress },
                { "Primary_Contact_Display_Name", mpEvent.PrimaryContact.PreferredName },
                { "Base_Url", _configWrapper.GetConfigValue("BaseUrl") }
            };

            var comm = _communicationRepository.GetTemplateAsCommunication(templateId,
                                                                           mpEvent.PrimaryContactId,
                                                                           mpEvent.PrimaryContact.EmailAddress,
                                                                           mpEvent.PrimaryContactId,
                                                                           mpEvent.PrimaryContact.EmailAddress,
                                                                           me.Contact_ID,
                                                                           me.Email_Address,
                                                                           mergeData);

            _communicationRepository.SendMessage(comm);
        }
Example #9
0
        public IObservable <int> SendAcceptanceEmail(ContactInvitation contactInvitation)
        {
            var templateId = _confiurationWrapper.GetConfigIntValue("WaiverEmailTemplateId");
            var template   = _communicationRepository.GetTemplate(templateId);

            // get the event name for the waiver...
            return(_eventParticipantRepository.GetEventParticpantByEventParticipantWaiver(contactInvitation.Invitation.SourceId).Select(ep =>
            {
                var mergeData = new Dictionary <string, object>
                {
                    { "Event_Name", ep.EventTitle },
                    { "Confirmation_Url", $"https://{_confiurationWrapper.GetConfigValue("BaseUrl")}/waivers/accept/{contactInvitation.Invitation.InvitationGuid}" }
                };

                var comm = _communicationRepository.GetTemplateAsCommunication(templateId,
                                                                               template.FromContactId,
                                                                               template.FromEmailAddress,
                                                                               template.ReplyToContactId,
                                                                               template.ReplyToEmailAddress,
                                                                               contactInvitation.Contact.ContactId,
                                                                               contactInvitation.Contact.EmailAddress,
                                                                               mergeData);
                return _communicationRepository.SendMessage(comm);
            }));
        }
Example #10
0
        public Result <MpPledge> AddAsTripParticipant(int ContactId, int PledgeCampaignID, string token)
        {
            var storedProc = _configurationWrapper.GetConfigValue("TripParticipantStoredProc");

            try
            {
                var fields = new Dictionary <string, object>
                {
                    { "@PledgeCampaignID", PledgeCampaignID },
                    { "@ContactId", ContactId }
                };
                var result = _ministryPlatformRestRepository.UsingAuthenticationToken(token).GetFromStoredProc <MpPledge>(storedProc, fields);
                if (result.Count > 0 && result[0].Count > 0)
                {
                    return(new Result <MpPledge>(true, result[0].FirstOrDefault()));
                }
                _logger.Debug($"Adding a trip particpant returned no results. The trip is already full.");
                return(new Result <MpPledge>(false, "Trip is already full"));
            }
            catch (Exception e)
            {
                _logger.Error($"Failed to call stored procedure #{storedProc}");
                _logger.Error(e.Message);
                throw;
            }
        }
Example #11
0
        public bool PasswordResetRequest(string username)
        {
            int user_ID    = 0;
            int contact_Id = 0;

            // validate the email on the server side to avoid erroneous or malicious requests
            try
            {
                user_ID    = _userService.GetUserIdByUsername(username);
                contact_Id = _userService.GetContactIdByUserId(user_ID);
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Could not find email {0} for password reset", JsonConvert.SerializeObject(username, Formatting.Indented)), ex);
                return(false);
            }

            // create a token -- see http://stackoverflow.com/questions/664673/how-to-implement-password-resets
            var resetArray = Encoding.UTF8.GetBytes(Guid.NewGuid() + username + System.DateTime.Now);
            RNGCryptoServiceProvider prov = new RNGCryptoServiceProvider();

            prov.GetBytes(resetArray);
            var    resetToken = Encoding.UTF8.GetString(resetArray);
            string cleanToken = Regex.Replace(resetToken, "[^A-Za-z0-9]", "");

            Dictionary <string, object> userUpdateValues = new Dictionary <string, object>();

            userUpdateValues["User_ID"]            = user_ID;
            userUpdateValues["PasswordResetToken"] = cleanToken; // swap out for real implementation
            _userService.UpdateUser(userUpdateValues);

            string baseURL   = _configurationWrapper.GetConfigValue("BaseURL");
            string resetLink = (@"https://" + baseURL + "/reset-password?token=" + cleanToken);

            // add the email here...
            var emailCommunication = new EmailCommunicationDTO
            {
                FromContactId = 7, // church admin contact id
                FromUserId    = 5, // church admin user id
                ToContactId   = contact_Id,
                TemplateId    = 13356,
                MergeData     = new Dictionary <string, object>
                {
                    { "resetlink", resetLink }
                }
            };

            try
            {
                _emailCommunication.SendEmail(emailCommunication);
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Could not send email {0} for password reset", JsonConvert.SerializeObject(username, Formatting.Indented)), ex);
                return(false);
            }
        }
Example #12
0
        public ServeController(IServeService serveService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory)
        {
            _serveService = serveService;
            _messageFactory = messageFactory;

            var eventQueueName = configuration.GetConfigValue("SignupToServeEventQueue");
            _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
            _messageFactory = messageFactory;
        }
        public TripApplicationController(ITripService tripService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory)
        {
            _tripService = tripService;
            _messageFactory = messageFactory;

            var eventQueueName = configuration.GetConfigValue("TripApplicationEventQueue");
            _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
            _messageFactory = messageFactory;
        }
Example #14
0
        public List <object> GetChildcareDashboard(int contactId)
        {
            var parms = new Dictionary <string, object> {
                { "Contact_ID", contactId }
            };
            var dashboardData = _ministryPlatformRest.GetFromStoredProc <object>(_configurationWrapper.GetConfigValue("ChildcareDashboardStoredProc"), parms);

            return(dashboardData);
        }
Example #15
0
        public ServeController(IServeService serveService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory, IUserImpersonationService userImpersonationService, IAuthenticationRepository authenticationRepository) : base(userImpersonationService, authenticationRepository)
        {
            _serveService   = serveService;
            _messageFactory = messageFactory;

            var eventQueueName = configuration.GetConfigValue("SignupToServeEventQueue");

            _eventQueue     = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
            _messageFactory = messageFactory;
        }
        public StripeEventController(IConfigurationWrapper configuration, IStripeEventService stripeEventService = null,
            IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null)
        {
            var b = configuration.GetConfigValue("StripeWebhookLiveMode");
            _liveMode = b != null && bool.Parse(b);

            b = configuration.GetConfigValue("StripeWebhookAsynchronousProcessingMode");
            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var eventQueueName = configuration.GetConfigValue("StripeWebhookEventQueueName");
                _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
            else
            {
                _stripeEventService = stripeEventService;
            }
        }
Example #17
0
        public TripApplicationController(ITripService tripService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory, IUserImpersonationService userImpersonationService) : base(userImpersonationService)
        {
            _tripService    = tripService;
            _messageFactory = messageFactory;

            var eventQueueName = configuration.GetConfigValue("TripApplicationEventQueue");

            _eventQueue     = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
            _messageFactory = messageFactory;
        }
 public TextCommunicationController(ITextCommunicationService textCommunicationService, IConfigurationWrapper configurationWrapper, IUserImpersonationService userImpersonationService,
                                    IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null, IMessageQueue messageQueue = null) : base(userImpersonationService)
 {
     _textCommunicationService = textCommunicationService;
     _eventQueueName           = configurationWrapper.GetConfigValue("ScheduledJobsQueueName");
     _streamReminderTemplateId = configurationWrapper.GetConfigIntValue("StreamReminderTemplate");
     _messageQueue             = messageQueue;
     _messageQueue.CreateQueue(_eventQueueName, QueueAccessMode.Send);
     _messageFactory = messageFactory;
 }
Example #19
0
 public ProfileController(IPersonService personService, IServeService serveService, IUserImpersonationService impersonationService, IDonorService donorService, IAuthenticationRepository authenticationService, IUserRepository userService, IContactRelationshipRepository contactRelationshipService, IConfigurationWrapper config, IUserImpersonationService userImpersonationService) : base(userImpersonationService, authenticationService)
 {
     _personService               = personService;
     _serveService                = serveService;
     _impersonationService        = impersonationService;
     _donorService                = donorService;
     _authenticationService       = authenticationService;
     _userService                 = userService;
     _contactRelationshipService  = contactRelationshipService;
     _allowedAdminGetProfileRoles = config.GetConfigValue("AdminGetProfileRoles").Split(',').Select(int.Parse).ToList();
 }
Example #20
0
        private Dictionary <string, object> SetupMergeData(string preferredName, int groupId)
        {
            var mergeData = new Dictionary <string, object>
            {
                { "BaseUrl", _configurationWrapper.GetConfigValue("BaseUrl") },
                { "GroupId", groupId },
                { "PreferredName", preferredName },
            };

            return(mergeData);
        }
        public StripeEventController(IConfigurationWrapper configuration, IStripeEventService stripeEventService = null,
                                     IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null)
        {
            var b = configuration.GetConfigValue("StripeWebhookLiveMode");

            _liveMode = b != null && bool.Parse(b);

            b             = configuration.GetConfigValue("StripeWebhookAsynchronousProcessingMode");
            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var eventQueueName = configuration.GetConfigValue("StripeWebhookEventQueueName");
                _eventQueue     = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
            else
            {
                _stripeEventService = stripeEventService;
            }
        }
Example #22
0
        public bool IsMemberOfEventGroup(int contactId, int eventId, string token)
        {
            var storedProc     = _configurationWrapper.GetConfigValue("IsCampEligibleStoredProc");
            var storedProcOpts = new Dictionary <string, object>
            {
                { "@ContactId", contactId },
                { "@EventID", eventId }
            };
            var result = _ministryPlatformRestRepository.UsingAuthenticationToken(token).GetFromStoredProc <MpStoredProcBool>(storedProc, storedProcOpts);

            if (result.Count <= 0)
            {
                return(false);
            }
            var mpStoredProcBool = result.FirstOrDefault();

            return(mpStoredProcBool != null &&
                   mpStoredProcBool.FirstOrDefault() != null &&
                   mpStoredProcBool.FirstOrDefault().isTrue);
        }
Example #23
0
        private RestClient GetBulkEmailClient()
        {
            var apiUrl = _configWrapper.GetConfigValue("BulkEmailApiUrl");
            var apiKey = _configWrapper.GetEnvironmentVarAsString("BULK_EMAIL_API_KEY");

            var client = new RestClient(apiUrl);

            client.Authenticator = new HttpBasicAuthenticator("noname", apiKey);

            return(client);
        }
Example #24
0
        public IObservable <string> GetUrlSegment()
        {
            string appCode   = _configWrapper.GetConfigValue("GroupLeaderAppCode");
            string paramName = _configWrapper.GetConfigValue("GroupLeaderApplicationUrlSegment");

            return(Observable.Create <string>(observer =>
            {
                try
                {
                    string urlSegment = _configWrapper.GetMpConfigValue(appCode, paramName, true);
                    observer.OnNext(urlSegment);
                }
                catch (Exception e)
                {
                    observer.OnError(new ApplicationException("Failed to get redirect url segment: ", e));
                }

                observer.OnCompleted();
                return Disposable.Empty;
            }));
        }
        public CheckScannerController(IConfigurationWrapper configuration,
                                      ICheckScannerService checkScannerService,
                                      IAuthenticationService authenticationService,
                                      ICommunicationService communicationService,
                                      ICryptoProvider cryptoProvider,
                                      IMessageQueueFactory messageQueueFactory = null,
                                      IMessageFactory messageFactory = null)
        {
            _checkScannerService = checkScannerService;
            _authenticationService = authenticationService;
            _communicationService = communicationService;
            _cryptoProvider = cryptoProvider;

            var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode");
            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName");
                // ReSharper disable once PossibleNullReferenceException
                _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
        }
        public GroupSearchService(IGroupRepository mpGroupService,
                                  IAttributeRepository attributeService,
                                  IConfigurationWrapper configurationWrapper)
        {
            _mpGroupService   = mpGroupService;
            _attributeService = attributeService;

            GroupGoalAttributeTypeId         = configurationWrapper.GetConfigIntValue("GroupGoalAttributeTypeId");
            GroupTypeAttributeTypeId         = configurationWrapper.GetConfigIntValue("GroupTypeAttributeTypeId");
            ParticipantGoalAttributeTypeId   = configurationWrapper.GetConfigIntValue("ParticipantGoalAttributeTypeId");
            GenderTypeAttributeTypeId        = configurationWrapper.GetConfigIntValue("GenderTypeAttributeTypeId");
            MaritalStatusTypeAttributeTypeId = configurationWrapper.GetConfigIntValue("MaritalStatusTypeAttributeTypeId");
            WeekdayTimesAttributeTypeId      = configurationWrapper.GetConfigIntValue("WeekdayTimesAttributeTypeId");
            WeekendTimesAttributeTypeId      = configurationWrapper.GetConfigIntValue("WeekendTimesAttributeTypeId");

            ParticipantJourneyTogetherAttributeId = configurationWrapper.GetConfigIntValue("ParticipantJourneyTogetherAttributeId");
            ParticipantGenderManAttributeId       = configurationWrapper.GetConfigIntValue("ParticipantGenderManAttributeId");
            ParticipantGenderWomanAttributeId     = configurationWrapper.GetConfigIntValue("ParticipantGenderWomanAttributeId");

            GroupTypeMixedAttributeId          = configurationWrapper.GetConfigIntValue("GroupTypeMixedAttributeId");
            GroupTypeMenAttributeId            = configurationWrapper.GetConfigIntValue("GroupTypeMenAttributeId");
            GroupTypeWomenAttributeId          = configurationWrapper.GetConfigIntValue("GroupTypeWomenAttributeId");
            GroupTypeMarriedCouplesAttributeId = configurationWrapper.GetConfigIntValue("GroupTypeMarriedCouplesAttributeId");

            GroupPetsAttributeTypeId = configurationWrapper.GetConfigIntValue("GroupPetsAttributeTypeId");
            GroupPetsCatAttributeId  = configurationWrapper.GetConfigIntValue("GroupPetsCatAttributeId");
            GroupPetsDogAttributeId  = configurationWrapper.GetConfigIntValue("GroupPetsDogAttributeId");

            GroupGoalConnectWithCommunity = configurationWrapper.GetConfigIntValue("GroupGoalConnectWithCommunity");
            GroupGoalMakeFriends          = configurationWrapper.GetConfigIntValue("GroupGoalMakeFriends");
            GroupGoalLearnAndGrow         = configurationWrapper.GetConfigIntValue("GroupGoalLearnAndGrow");
            GroupGoalMentorOthers         = configurationWrapper.GetConfigIntValue("GroupGoalMentorOthers");

            ParticipantGoalNotSure          = configurationWrapper.GetConfigIntValue("ParticipantGoalNotSure");
            ParticipantGoalGrowSpiritually  = configurationWrapper.GetConfigIntValue("ParticipantGoalGrowSpiritually");
            ParticipantGoalLearnFromSomeone = configurationWrapper.GetConfigIntValue("ParticipantGoalLearnFromSomeone");
            ParticipantGoalMakeFriends      = configurationWrapper.GetConfigIntValue("ParticipantGoalMakeFriends");

            _inMarketZipCodes     = ParseZipCodes(configurationWrapper.GetConfigValue("InMarketZipCodes"));
            MaxGroupSearchResults = configurationWrapper.GetConfigIntValue("MaxGroupSearchResults");

            _goalMatches = new Dictionary <int, int>()
            {
                { GroupGoalConnectWithCommunity, ParticipantGoalNotSure },
                { GroupGoalMakeFriends, ParticipantGoalMakeFriends },
                { GroupGoalLearnAndGrow, ParticipantGoalGrowSpiritually },
                { GroupGoalMentorOthers, ParticipantGoalLearnFromSomeone },
            };
        }
        public GroupToolService(
            IGroupToolRepository groupToolRepository,
            IGroupRepository groupRepository,
            IGroupService groupService,
            IParticipantRepository participantRepository,
            ICommunicationRepository communicationRepository,
            IContentBlockService contentBlockService,
            IConfigurationWrapper configurationWrapper,
            IInvitationRepository invitationRepository,
            IAddressProximityService addressProximityService,
            IContactRepository contactRepository,
            IAddressProximityService addressMatrixService,
            IEmailCommunication emailCommunicationService,
            IAttributeService attributeService)
        {
            _groupToolRepository       = groupToolRepository;
            _groupRepository           = groupRepository;
            _groupService              = groupService;
            _participantRepository     = participantRepository;
            _communicationRepository   = communicationRepository;
            _contentBlockService       = contentBlockService;
            _invitationRepository      = invitationRepository;
            _addressProximityService   = addressProximityService;
            _contactRepository         = contactRepository;
            _addressMatrixService      = addressMatrixService;
            _emailCommunicationService = emailCommunicationService;
            _attributeService          = attributeService;

            _defaultGroupContactEmailId = configurationWrapper.GetConfigIntValue("DefaultGroupContactEmailId");
            _defaultAuthorUserId        = configurationWrapper.GetConfigIntValue("DefaultAuthorUser");
            _groupRoleLeaderId          = configurationWrapper.GetConfigIntValue("GroupRoleLeader");
            _defaultGroupRoleId         = configurationWrapper.GetConfigIntValue("Group_Role_Default_ID");
            _groupRequestPendingReminderEmailTemplateId = configurationWrapper.GetConfigIntValue("GroupRequestPendingReminderEmailTemplateId");
            _attributeTypeGroupCategory = configurationWrapper.GetConfigIntValue("GroupCategoryAttributeTypeId");

            _removeParticipantFromGroupEmailTemplateId = configurationWrapper.GetConfigIntValue("RemoveParticipantFromGroupEmailTemplateId");

            _domainId = configurationWrapper.GetConfigIntValue("DomainId");
            _groupEndedParticipantEmailTemplate = Convert.ToInt32(configurationWrapper.GetConfigIntValue("GroupEndedParticipantEmailTemplate"));
            _groupRequestToJoinEmailTemplate    = configurationWrapper.GetConfigIntValue("GroupRequestToJoinEmailTemplate");
            _baseUrl = configurationWrapper.GetConfigValue("BaseURL");
            _addressMatrixSearchDepth = configurationWrapper.GetConfigIntValue("AddressMatrixSearchDepth");

            _smallGroupTypeId  = configurationWrapper.GetConfigIntValue("SmallGroupTypeId");
            _onsiteGroupTypeId = configurationWrapper.GetConfigIntValue("OnsiteGroupTypeId");
        }
Example #28
0
        private void SendEmails(string itemId, string title)
        {
            var apiUser  = _gateway.GetApiUserInformation();
            var apiToken = apiUser.userToken.ToString();

            var recipientContactIds = _email.GetRecipientContactIds(apiToken);

            var templateId  = _configuration.GetConfigIntValue("FlagPostTemplateId");
            var coreWebsite = _configuration.GetConfigValue("CoreWebsite");
            var link        = coreWebsite + "corkboard/#/detail/" + itemId;

            int fromContactId = apiUser.userId;

            foreach (var recipientContactId in recipientContactIds)
            {
                _email.SendEmail(apiToken, fromContactId, recipientContactId, templateId, title, link);
            }
        }
Example #29
0
        public void SendEmail(EmailCommunicationDTO email, string token)
        {
            var template = _communicationService.GetTemplate(email.TemplateId);

            if (token == null && email.FromUserId == null && template.FromContactId == 0)
            {
                throw (new InvalidOperationException("Must provide either email.FromUserId from  or an authentication token."));
            }

            var replyToContactId = email.ReplyToContactId ?? template.ReplyToContactId;
            var replyTo          = new MpContact {
                ContactId = replyToContactId, EmailAddress = _communicationService.GetEmailFromContactId(replyToContactId)
            };

            var fromContactId = email.FromContactId ?? template.FromContactId;
            var from          = new MpContact {
                ContactId = fromContactId, EmailAddress = _communicationService.GetEmailFromContactId(fromContactId)
            };

            MpContact to = GetMpContactFromEmailCommunicationDto(email);

            var communication = new MpCommunication
            {
                DomainId       = DomainID,
                AuthorUserId   = email.FromUserId ?? DefaultAuthorUserId,
                TemplateId     = email.TemplateId,
                EmailBody      = template.Body,
                EmailSubject   = template.Subject,
                ReplyToContact = replyTo,
                FromContact    = from,
                StartDate      = email.StartDate ?? DateTime.Now,
                MergeData      = email.MergeData,
                ToContacts     = new List <MpContact>()
            };

            communication.ToContacts.Add(to);

            if (!communication.MergeData.ContainsKey("BaseUrl"))
            {
                communication.MergeData.Add("BaseUrl", _configurationWrapper.GetConfigValue("BaseUrl"));
            }

            _communicationService.SendMessage(communication);
        }
Example #30
0
        private Dictionary <string, object> SetupAnywhereMergeData(AnywhereRegistration registration, string projectLeaderName)
        {
            var adultsParticipating = registration.SpouseParticipation ? 2 : 1;
            var birthDate           = DateTime.Parse(registration.Self.DateOfBirth);
            var merge = new Dictionary <string, object>
            {
                { "Nickname", registration.Self.FirstName },
                { "LastName", registration.Self.LastName },
                { "Participant_Email_Address", registration.Self.EmailAddress },
                { "Date_Of_Birth", birthDate.Month + "/" + birthDate.Day + "/" + birthDate.Year },
                { "Mobile_Phone", registration.Self.MobilePhone },
                { "Spouse_Participating", registration.SpouseParticipation ? "Yes": "No" },
                { "Number_Of_Children", registration.NumberOfChildren },
                { "Group_Connector", projectLeaderName },
                { "Adults_Participating", adultsParticipating },
                { "Total_Volunteers", registration.NumberOfChildren + adultsParticipating },
                { "Base_Url", _configurationWrapper.GetConfigValue("BaseUrl") }
            };

            return(merge);
        }
Example #31
0
        public DonorService(IDonorRepository mpDonorService, IContactRepository mpContactService,
                            Interfaces.IPaymentProcessorService paymentService, IConfigurationWrapper configurationWrapper,
                            IPledgeRepository pledgeService)
        {
            _mpDonorService   = mpDonorService;
            _mpContactService = mpContactService;
            _paymentService   = paymentService;
            _pledgeService    = pledgeService;

            _guestGiverDisplayName = configurationWrapper.GetConfigValue("GuestGiverContactDisplayName");

            _statementFrequencyNever     = configurationWrapper.GetConfigIntValue("DonorStatementFrequencyNever");
            _statementFrequencyQuarterly = configurationWrapper.GetConfigIntValue("DonorStatementFrequencyQuarterly");
            _statementTypeIndividual     = configurationWrapper.GetConfigIntValue("DonorStatementTypeIndividual");
            _statementMethodNone         = configurationWrapper.GetConfigIntValue("DonorStatementMethodNone");
            _statementMethodPostalMail   = configurationWrapper.GetConfigIntValue("DonorStatementMethodPostalMail");
            _notSiteSpecificCongregation = configurationWrapper.GetConfigIntValue("NotSiteSpecificCongregation");
            _capitalCampaignPledgeTypeId = configurationWrapper.GetConfigIntValue("PledgeCampaignTypeCapitalCampaign");

            _recurringGiftSetupEmailTemplateId  = configurationWrapper.GetConfigIntValue("RecurringGiftSetupEmailTemplateId");
            _recurringGiftUpdateEmailTemplateId = configurationWrapper.GetConfigIntValue("RecurringGiftUpdateEmailTemplateId");
            _recurringGiftCancelEmailTemplateId = configurationWrapper.GetConfigIntValue("RecurringGiftCancelEmailTemplateId");
        }
Example #32
0
        public DonorService(IDonorService mpDonorService, IContactService mpContactService,
            Interfaces.IPaymentService paymentService, IConfigurationWrapper configurationWrapper,
            IAuthenticationService authenticationService, IPledgeService pledgeService)
        {
            _mpDonorService = mpDonorService;
            _mpContactService = mpContactService;
            _paymentService = paymentService;
            _authenticationService = authenticationService;
            _pledgeService = pledgeService;

            _guestGiverDisplayName = configurationWrapper.GetConfigValue("GuestGiverContactDisplayName");

            _statementFrequencyNever = configurationWrapper.GetConfigIntValue("DonorStatementFrequencyNever");
            _statementFrequencyQuarterly = configurationWrapper.GetConfigIntValue("DonorStatementFrequencyQuarterly");
            _statementTypeIndividual = configurationWrapper.GetConfigIntValue("DonorStatementTypeIndividual");
            _statementMethodNone = configurationWrapper.GetConfigIntValue("DonorStatementMethodNone");
            _statementMethodPostalMail = configurationWrapper.GetConfigIntValue("DonorStatementMethodPostalMail");
            _notSiteSpecificCongregation = configurationWrapper.GetConfigIntValue("NotSiteSpecificCongregation");
            _capitalCampaignPledgeTypeId = configurationWrapper.GetConfigIntValue("PledgeCampaignTypeCapitalCampaign");

            _recurringGiftSetupEmailTemplateId = configurationWrapper.GetConfigIntValue("RecurringGiftSetupEmailTemplateId");
            _recurringGiftUpdateEmailTemplateId = configurationWrapper.GetConfigIntValue("RecurringGiftUpdateEmailTemplateId");
            _recurringGiftCancelEmailTemplateId = configurationWrapper.GetConfigIntValue("RecurringGiftCancelEmailTemplateId");
        }
        public List <MpRecordID> CreateContact(MpContact minorContact)
        {
            var storedProc = _configurationWrapper.GetConfigValue("CreateContactStoredProc");
            var apiToken   = _apiUserRepository.GetToken();
            var fields     = new Dictionary <String, Object>
            {
                { "@FirstName", minorContact.FirstName },
                { "@LastName", minorContact.LastName },
                { "@MiddleName", minorContact.MiddleName },
                { "@PreferredName", minorContact.PreferredName },
                { "@NickName", minorContact.Nickname },
                { "@Birthdate", minorContact.BirthDate },
                { "@Gender", minorContact.Gender },
                { "@SchoolAttending", minorContact.SchoolAttending },
                { "@HouseholdId", minorContact.HouseholdId },
                { "@HouseholdPosition", minorContact.HouseholdPositionId },
                { "@MobilePhone", minorContact.MobilePhone }
            };

            var result        = _ministryPlatformRest.UsingAuthenticationToken(apiToken).GetFromStoredProc <MpRecordID>(storedProc, fields);
            var contactIdList = result.FirstOrDefault() ?? new List <MpRecordID>();

            return(contactIdList);
        }
Example #34
0
        public List <MpChildcareDashboard> GetChildcareDashboard(int contactId)
        {
            var apiToken = _apiUserRepository.GetToken();
            var parms    = new Dictionary <string, object> {
                { "Contact_ID", contactId }, { "Domain_ID", 1 }
            };
            var dashboardData      = _ministryPlatformRest.UsingAuthenticationToken(apiToken).GetFromStoredProc <MpChildcareDashboard>(_configurationWrapper.GetConfigValue("ChildcareDashboardStoredProc"), parms);
            var childcareDashboard = dashboardData.FirstOrDefault() ?? new List <MpChildcareDashboard>();

            return(childcareDashboard);
        }
Example #35
0
        public GroupToolService(
            IGroupToolRepository groupToolRepository,
            IGroupRepository groupRepository,
            IGroupService groupService,
            IParticipantRepository participantRepository,
            ICommunicationRepository communicationRepository,
            IContentBlockService contentBlockService,
            IConfigurationWrapper configurationWrapper,
            IInvitationRepository invitationRepository,
            IAddressProximityService addressProximityService,
            IContactRepository contactRepository,
            IAddressProximityService addressMatrixService,
            IEmailCommunication emailCommunicationService,
            IAttributeService attributeService,
            IAddressService addressService,
            IAnalyticsService analyticsService,
            IFinderRepository finderRepository
            )
        {
            _groupToolRepository       = groupToolRepository;
            _groupRepository           = groupRepository;
            _groupService              = groupService;
            _participantRepository     = participantRepository;
            _communicationRepository   = communicationRepository;
            _contentBlockService       = contentBlockService;
            _invitationRepository      = invitationRepository;
            _addressProximityService   = addressProximityService;
            _contactRepository         = contactRepository;
            _addressMatrixService      = addressMatrixService;
            _emailCommunicationService = emailCommunicationService;
            _attributeService          = attributeService;
            _addressService            = addressService;
            _analyticsService          = analyticsService;
            _finderRepository          = finderRepository;

            _defaultGroupContactEmailId = configurationWrapper.GetConfigIntValue("DefaultGroupContactEmailId");
            _defaultAuthorUserId        = configurationWrapper.GetConfigIntValue("DefaultAuthorUser");
            _groupRoleLeaderId          = configurationWrapper.GetConfigIntValue("GroupRoleLeader");
            _defaultGroupRoleId         = configurationWrapper.GetConfigIntValue("Group_Role_Default_ID");
            _groupRequestPendingReminderEmailTemplateId = configurationWrapper.GetConfigIntValue("GroupRequestPendingReminderEmailTemplateId");
            _attributeTypeGroupCategory = configurationWrapper.GetConfigIntValue("GroupCategoryAttributeTypeId");

            _genericGroupForCMSMergeEmailTemplateId = configurationWrapper.GetConfigIntValue("GenericGroupForCMSMergeEmailTemplateId");

            _connectCommunicationTypeEmailSmallGroupLeader = configurationWrapper.GetConfigIntValue("ConnectCommunicationTypeEmailSmallGroupLeader");
            _connectCommunicationStatusNA = configurationWrapper.GetConfigIntValue("ConnectCommunicationStatusNA");
            _domainId = configurationWrapper.GetConfigIntValue("DomainId");
            _groupEndedParticipantEmailTemplate      = configurationWrapper.GetConfigIntValue("GroupEndedParticipantEmailTemplate");
            _gatheringHostAcceptTemplate             = configurationWrapper.GetConfigIntValue("GatheringHostAcceptTemplate");
            _gatheringHostDenyTemplate               = configurationWrapper.GetConfigIntValue("GatheringHostDenyTemplate");
            _groupRequestToJoinEmailTemplate         = configurationWrapper.GetConfigIntValue("GroupRequestToJoinEmailTemplate");
            _anywhereGroupRequestToJoinEmailTemplate = configurationWrapper.GetConfigIntValue("AnywhereGroupRequestToJoinEmailTemplate");
            _baseUrl = configurationWrapper.GetConfigValue("BaseURL");
            _addressMatrixSearchDepth = configurationWrapper.GetConfigIntValue("AddressMatrixSearchDepth");

            _smallGroupTypeId              = configurationWrapper.GetConfigIntValue("SmallGroupTypeId");
            _onsiteGroupTypeId             = configurationWrapper.GetConfigIntValue("OnsiteGroupTypeId");
            _anywhereGroupType             = configurationWrapper.GetConfigIntValue("AnywhereGroupTypeId");
            _connectGatheringStatusAccept  = configurationWrapper.GetConfigIntValue("ConnectCommunicationStatusAccepted");
            _connectGatheringStatusDeny    = configurationWrapper.GetConfigIntValue("ConnectCommunicationStatusDeclined");
            _connectGatheringRequestToJoin = configurationWrapper.GetConfigIntValue("ConnectCommunicationTypeRequestToJoinGathering");
            _connectCommunicationTypeRequestToJoinSmallGroup = configurationWrapper.GetConfigIntValue("ConnectCommunicationTypeRequestToJoinSmallGroup");
            _emailAuthorId          = configurationWrapper.GetConfigIntValue("EmailAuthorId");
            _groupRoleTrialMemberId = configurationWrapper.GetConfigIntValue("GroupsTrialMemberRoleId");
        }