private HtmlElement SetupTable(List <RegisterEventObj> regData, MpEvent evnt) { var tableAttrs = new Dictionary <string, string>() { { "width", "100%" }, { "border", "1" }, { "cellspacing", "0" }, { "cellpadding", "5" } }; var cellAttrs = new Dictionary <string, string>() { { "align", "center" } }; var htmlrows = regData.Select(rsvp => { var p = _contactService.GetContactByParticipantId(rsvp.ParticipantId); return(new HtmlElement("tr") .Append(new HtmlElement("td", cellAttrs, evnt.EventStartDate.ToShortDateString())) .Append(new HtmlElement("td", cellAttrs, p.First_Name + " " + p.Last_Name)) .Append(new HtmlElement("td", cellAttrs, evnt.EventStartDate.ToShortTimeString())) .Append(new HtmlElement("td", cellAttrs, evnt.EventEndDate.ToShortTimeString())) .Append(new HtmlElement("td", cellAttrs, evnt.Congregation))); }).ToList(); return(new HtmlElement("table", tableAttrs) .Append(SetupTableHeader) .Append(htmlrows)); }
public void TestPostParticipantToCommunityGroupIsSuccessful() { const int groupId = 456; List <ParticipantSignup> particpantIdToAdd = new List <ParticipantSignup> { new ParticipantSignup() { particpantId = 90210, childCareNeeded = false, SendConfirmationEmail = true }, new ParticipantSignup() { particpantId = 41001, childCareNeeded = false, SendConfirmationEmail = true } }; List <MpEvent> events = new List <MpEvent>(); MpEvent e1 = new MpEvent(); e1.EventId = 101; MpEvent e2 = new MpEvent(); e2.EventId = 202; events.Add(e1); events.Add(e2); var participantsAdded = new List <Dictionary <string, object> > { new Dictionary <string, object> { { "123", "456" } }, new Dictionary <string, object> { { "abc", "def" } }, }; _groupServiceMock.Setup(mocked => mocked.addParticipantsToGroup(groupId, particpantIdToAdd)); IHttpActionResult result = _fixture.Post(groupId, particpantIdToAdd); _authenticationServiceMock.VerifyAll(); _groupServiceMock.VerifyAll(); Assert.IsNotNull(result); Assert.IsInstanceOf(typeof(OkResult), result); }
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); } }
public void ShouldSendPrimaryContactReminderEmails() { const string search = ""; const string apiToken = "qwerty1234"; var defaultContact = new MpMyContact() { Contact_ID = 321, Email_Address = "*****@*****.**" }; var testEvent = new MpEvent() { EventId = 32, EventStartDate = new DateTime(), EventEndDate = new DateTime().AddHours(2), PrimaryContact = new MpContact() { EmailAddress = "*****@*****.**", ContactId = 4321 } }; var testEventList = new List <MpEvent>() { testEvent }; _apiUserService.Setup(m => m.GetToken()).Returns(apiToken); _eventService.Setup(m => m.EventsByPageViewId(apiToken, 2205, search)).Returns(testEventList); var eventList = testEventList.Select(evt => new crds_angular.Models.Crossroads.Events.Event() { name = evt.EventTitle, EventId = evt.EventId, EndDate = evt.EventEndDate, StartDate = evt.EventStartDate, EventType = evt.EventType, location = evt.Congregation, PrimaryContactEmailAddress = evt.PrimaryContact.EmailAddress, PrimaryContactId = evt.PrimaryContact.ContactId }); eventList.ForEach(evt => { 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() } }; var contact = new MpContact() { ContactId = defaultContact.Contact_ID, EmailAddress = defaultContact.Email_Address }; var fakeCommunication = new MpCommunication() { AuthorUserId = defaultContact.Contact_ID, DomainId = 1, EmailBody = "Test event email stuff", EmailSubject = "Test Event Reminder", FromContact = contact, MergeData = mergeData, ReplyToContact = contact, TemplateId = 14909, ToContacts = new List <MpContact>() { contact } }; var testContact = new MpMyContact() { Contact_ID = 9876, Email_Address = "*****@*****.**" }; _contactService.Setup(m => m.GetContactById(9876)).Returns(testContact); _communicationService.Setup(m => m.GetTemplateAsCommunication(14909, testContact.Contact_ID, testContact.Email_Address, evt.PrimaryContactId, evt.PrimaryContactEmailAddress, evt.PrimaryContactId, evt.PrimaryContactEmailAddress, mergeData)).Returns(fakeCommunication); _communicationService.Setup(m => m.SendMessage(fakeCommunication, false)); _communicationService.Verify(); }); _fixture.EventsReadyForPrimaryContactReminder(apiToken); _eventService.Verify(); }
public void TestGetEventReservation() { var e = new MpEvent { EventTitle = "title", CongregationId = 12, EventEndDate = DateTime.Today.AddDays(2), EventStartDate = DateTime.Today.AddDays(1), ReminderDaysPriorId = 34 }; _eventService.Setup(mocked => mocked.GetEvent(123)).Returns(e); var r = new List <MpRoomReservationDto> { new MpRoomReservationDto { Cancelled = false, Hidden = false, RoomLayoutId = 1, Notes = "notes 1", RoomId = 11, EventRoomId = 111, Capacity = 1111, CheckinAllowed = false, Name = "name 1", Label = "label 1" }, new MpRoomReservationDto { Cancelled = true, Hidden = true, RoomLayoutId = 2, Notes = "notes 2", RoomId = 22, EventRoomId = 222, Capacity = 2222, CheckinAllowed = true, Name = "name 2", Label = "label 2" } }; _roomService.Setup(mocked => mocked.GetRoomReservations(123)).Returns(r); var q = new List <List <MpEquipmentReservationDto> >() { new List <MpEquipmentReservationDto> { new MpEquipmentReservationDto { Cancelled = false, EquipmentId = 1, EventRoomId = 11, QuantityRequested = 111 }, new MpEquipmentReservationDto { Cancelled = true, EquipmentId = 2, EventRoomId = 22, QuantityRequested = 222 } }, new List <MpEquipmentReservationDto> { new MpEquipmentReservationDto { Cancelled = false, EquipmentId = 3, EventRoomId = 33, QuantityRequested = 333 }, new MpEquipmentReservationDto { Cancelled = true, EquipmentId = 4, EventRoomId = 44, QuantityRequested = 444 } } }; var g = new List <MpEventGroup> { new MpEventGroup() { GroupId = 1 } }; _equipmentService.Setup(mocked => mocked.GetEquipmentReservations(123, r[0].RoomId)).Returns(q[0]); _equipmentService.Setup(mocked => mocked.GetEquipmentReservations(123, r[1].RoomId)).Returns(q[1]); _eventService.Setup(mocked => mocked.GetEventGroupsForEventAPILogin(123)).Returns(g); _groupService.Setup(mocked => mocked.getGroupDetails(g[0].GroupId)).Returns(new MpGroup()); var response = _fixture.GetEventReservation(123); _eventService.VerifyAll(); _roomService.VerifyAll(); _equipmentService.VerifyAll(); Assert.NotNull(response); Assert.AreEqual(e.EventTitle, response.Title); Assert.AreEqual(e.CongregationId, response.CongregationId); Assert.AreEqual(e.EventStartDate, response.StartDateTime); Assert.AreEqual(e.EventEndDate, response.EndDateTime); Assert.AreEqual(e.ReminderDaysPriorId, response.ReminderDaysId); Assert.IsNotNull(response.Rooms); Assert.AreEqual(r.Count, response.Rooms.Count); for (var i = 0; i < r.Count; i++) { Assert.AreEqual(r[i].Cancelled, response.Rooms[i].Cancelled); Assert.AreEqual(r[i].Hidden, response.Rooms[i].Hidden); Assert.AreEqual(r[i].RoomLayoutId, response.Rooms[i].LayoutId); Assert.AreEqual(r[i].Notes, response.Rooms[i].Notes); Assert.AreEqual(r[i].RoomId, response.Rooms[i].RoomId); Assert.AreEqual(r[i].EventRoomId, response.Rooms[i].RoomReservationId); Assert.AreEqual(r[i].Capacity, response.Rooms[i].Capacity); Assert.AreEqual(r[i].CheckinAllowed, response.Rooms[i].CheckinAllowed); Assert.AreEqual(r[i].Name, response.Rooms[i].Name); Assert.AreEqual(r[i].Label, response.Rooms[i].Label); Assert.IsNotNull(response.Rooms[i].Equipment); Assert.AreEqual(q[i].Count, response.Rooms[i].Equipment.Count); for (var j = 0; j < q[i].Count; j++) { Assert.AreEqual(q[i][j].Cancelled, response.Rooms[i].Equipment[j].Cancelled); Assert.AreEqual(q[i][j].EquipmentId, response.Rooms[i].Equipment[j].EquipmentId); Assert.AreEqual(q[i][j].EventEquipmentId, response.Rooms[i].Equipment[j].EquipmentReservationId); Assert.AreEqual(q[i][j].QuantityRequested, response.Rooms[i].Equipment[j].QuantityRequested); } } }