public void CreateGroupInquiry(MpInquiry inquiry) { var values = new Dictionary <string, object> { { "Contact_ID", inquiry.ContactId }, { "Group_ID", inquiry.GroupId }, { "Email", inquiry.EmailAddress }, { "Phone", inquiry.PhoneNumber }, { "First_Name", inquiry.FirstName }, { "Last_Name", inquiry.LastName }, { "Inquiry_Date", System.DateTime.Now } }; WithApiLogin <int>(token => { try { ministryPlatformService.CreateSubRecord(_configurationWrapper.GetConfigIntValue("GroupInquiresSubPage"), inquiry.GroupId, values, token); return(1); } catch (Exception e) { throw new ApplicationException("Error creating group inquiry: " + e.Message); } }); }
public void SubmitInquiry(string token, int groupId) { var participant = _participantRepository.GetParticipantRecord(token); var contact = _contactRepository.GetContactById(participant.ContactId); // check to see if the inquiry is going against a group where a person is already a member or has an outstanding request to join var requestsForContact = _groupToolRepository.GetInquiries(groupId).Where(r => r.ContactId == participant.ContactId && r.Placed == null); var participants = _groupRepository.GetGroupParticipants(groupId, true).Where(r => r.ContactId == participant.ContactId); if (requestsForContact.Any() || participants.Any()) { throw new ExistingRequestException("User is already member or has request"); } var mpInquiry = new MpInquiry { ContactId = participant.ContactId, GroupId = groupId, EmailAddress = participant.EmailAddress, PhoneNumber = contact.Home_Phone, FirstName = contact.Nickname, LastName = contact.Last_Name, RequestDate = DateTime.Now }; _groupRepository.CreateGroupInquiry(mpInquiry); var group = _groupService.GetGroupDetails(groupId); var leaders = group.Participants. Where(groupParticipant => groupParticipant.GroupRoleId == _groupRoleLeaderId).ToList(); var Requestor = "<i>" + contact.Nickname + " " + contact.Last_Name + "</i> "; foreach (var leader in leaders) { var mergeData = new Dictionary <string, object> { { "Name", leader.NickName }, { "Requestor", Requestor } }; SendSingleGroupParticipantEmail(leader, _groupRequestToJoinEmailTemplate, mergeData); } }
public void SubmitInquiry(string token, int groupId, bool doSendEmail) { var participant = _participantRepository.GetParticipantRecord(token); var contact = _contactRepository.GetContactById(participant.ContactId); // check to see if the inquiry is going against a group where a person is already a member or has an outstanding request to join var requestsForContact = _groupToolRepository.GetInquiries(groupId).Where(r => r.ContactId == participant.ContactId && r.Placed == null); var participants = _groupRepository.GetGroupParticipants(groupId, true).Where(r => r.ContactId == participant.ContactId); if (participants.Any()) { throw new ExistingRequestException("User already a member"); } if (requestsForContact.Any()) { throw new ExistingRequestException("User already has request"); } var mpInquiry = new MpInquiry { ContactId = participant.ContactId, GroupId = groupId, EmailAddress = participant.EmailAddress, PhoneNumber = contact.Home_Phone, FirstName = contact.Nickname, LastName = contact.Last_Name, RequestDate = DateTime.Now }; _groupRepository.CreateGroupInquiry(mpInquiry); var group = _groupService.GetGroupDetails(groupId); var leaders = group.Participants. Where(groupParticipant => groupParticipant.GroupRoleId == _groupRoleLeaderId).ToList(); // Call Analytics var props = new EventProperties { { "Name", group.GroupName }, { "City", group?.Address?.City }, { "State", group?.Address?.State }, { "Zip", group?.Address?.PostalCode } }; _analyticsService.Track(contact.Contact_ID.ToString(), "RequestedToJoinGroup", props); if (doSendEmail) { foreach (var leader in leaders) { if (group.GroupTypeId == _anywhereGroupType) { var Requestor = "<i>" + contact.Nickname + " " + contact.Last_Name.Substring(0, 1) + "." + "</i> "; var RequestorSub = contact.Nickname + " " + contact.Last_Name.Substring(0, 1) + "."; var mergeData = new Dictionary <string, object> { { "Name", leader.NickName }, { "Requestor", Requestor }, { "RequestorSub", RequestorSub } }; SendSingleGroupParticipantEmail(leader, _anywhereGroupRequestToJoinEmailTemplate, mergeData); } else { var Requestor = "<i>" + contact.Nickname + " " + contact.Last_Name + "</i> "; var mergeData = new Dictionary <string, object> { { "Name", leader.NickName }, { "Requestor", Requestor } }; SendSingleGroupParticipantEmail(leader, _groupRequestToJoinEmailTemplate, mergeData); } } } }