public Opportunity GetOpportunityById(int opportunityId, string token)
 {
     var opp = _ministryPlatformService.GetRecordDict(_opportunityPage, opportunityId, token);
     var opportunity = new Opportunity
     {
         OpportunityId = opportunityId,
         OpportunityName = opp.ToString("Opportunity_Title"),
         EventType = opp.ToString("Event_Type_ID_Text"),
         EventTypeId = opp.ToInt("Event_Type_ID"),
         RoleTitle = opp.ToString("Group_Role_ID_Text"),
         MaximumNeeded = opp.ToNullableInt("Maximum_Needed"),
         MinimumNeeded = opp.ToNullableInt("Minimum_Needed"),
         GroupContactId = opp.ToInt("Contact_Person"),
         GroupContactName = opp.ToString("Contact_Person_Text"),
         GroupName = opp.ToString("Add_to_Group_Text"),
         GroupId = opp.ToInt("Add_to_Group"),
         ShiftStart = TimeSpan.Parse(opp.ToString("Shift_Start")),
         ShiftEnd = TimeSpan.Parse(opp.ToString("Shift_End")),
         Room = opp.ToString("Room")
     };
     return opportunity;
 }
示例#2
0
 private Dictionary<string, object> SetupMergeData(int contactId,
                                                   int opportunityId,
                                                   Opportunity previousOpportunity,
                                                   Opportunity currentOpportunity,
                                                   DateTime startDate,
                                                   DateTime endDate,
                                                   MyContact groupContact,
                                                   String htmlTable)
 {
     MyContact volunteer = _contactService.GetContactById(contactId);
     return new Dictionary<string, object>
     {
         {"Opportunity_Name", opportunityId == 0 ? "Not Available" : currentOpportunity.OpportunityName},
         {"Start_Date", startDate.ToShortDateString()},
         {"End_Date", endDate.ToShortDateString()},
         {"Shift_Start", currentOpportunity.ShiftStart.FormatAsString() ?? string.Empty},
         {"Shift_End", currentOpportunity.ShiftEnd.FormatAsString() ?? string.Empty},
         {"Room", currentOpportunity.Room ?? string.Empty},
         {"Group_Contact", groupContact.Nickname + " " + groupContact.Last_Name},
         {"Group_Name", currentOpportunity.GroupName},
         {
             "Previous_Opportunity_Name",
             previousOpportunity != null ? previousOpportunity.OpportunityName : @"Not Available"
         },
         {"Volunteer_Name", volunteer.Nickname + " " + volunteer.Last_Name},
         {"Html_Table", htmlTable}
     };
 }
示例#3
0
 private static Opportunity PreviousOpportunity(Dictionary<string, object> response, Opportunity previousOpportunity)
 {
     if (response.ToNullableObject<Opportunity>("previousOpportunity") != null)
     {
         previousOpportunity = response.ToNullableObject<Opportunity>("previousOpportunity");
     }
     return previousOpportunity;
 }
        public void RespondToServeOpportunityYesEveryWeek()
        {
            const int contactId = 8;
            const int opportunityId = 12;
            const int eventTypeId = 3;
            const bool signUp = true;
            const bool alternateWeeks = false;
            var oppIds = new List<int>() {1, 2, 3, 4, 5};

            SetUpRSVPMocks(contactId, eventTypeId, opportunityId, signUp, SetupMockEvents());

            _configurationWrapper.Setup(m => m.GetConfigIntValue("DefaultContactEmailId")).Returns(1234);
            _contactService.Setup(m => m.GetContactById(1234)).Returns(new MyContact()
            {
                Email_Address = "*****@*****.**",
                Contact_ID = 1234567890
            });

            // The current Opportunity
            _opportunityService.Setup(m => m.GetOpportunityById(opportunityId, It.IsAny<string>()))
                .Returns(fakeOpportunity);

            SaveRsvpDto dto = new SaveRsvpDto
            {
                ContactId = contactId,
                OpportunityId = opportunityId,
                OpportunityIds = oppIds,
                EventTypeId = eventTypeId,
                AlternateWeeks = alternateWeeks,
                StartDateUnix = new DateTime(2015, 1, 1).ToUnixTime(),
                EndDateUnix = new DateTime(2016, 1, 1).ToUnixTime(),
                SignUp = signUp
            };

            _fixture.SaveServeRsvp("1234567", dto);

            _participantService.VerifyAll();
            _eventService.Verify(
                m =>
                    m.GetEventsByTypeForRange(eventTypeId, It.IsAny<DateTime>(), It.IsAny<DateTime>(),
                        It.IsAny<string>()), Times.Exactly(1));
            _eventService.Verify(m => m.RegisterParticipantForEvent(47, It.IsAny<int>(), 0, 0), Times.Exactly(5));
            _opportunityService.Verify(
                (m => m.RespondToOpportunity(47, opportunityId, It.IsAny<string>(), It.IsAny<int>(), signUp)),
                Times.Exactly(5));

            Opportunity o = new Opportunity();
            o.OpportunityName = "Whatever";
            o.OpportunityId = opportunityId;
            o.ShiftStart = new TimeSpan();
            o.ShiftEnd = new TimeSpan();
            o.Room = "123";

            _opportunityService.Setup(m => m.GetOpportunityById(opportunityId, It.IsAny<string>())).Returns(o);
        }
        public void OpportunityCapacityMinAndMaxNull()
        {
            const int opportunityId = 9999;
            const int eventId = 1000;

            var opportunity = new Opportunity();
            opportunity.MaximumNeeded = null;
            opportunity.MinimumNeeded = null;
            opportunity.OpportunityId = opportunityId;
            opportunity.Responses = new List<Response>();

            _opportunityService.Setup(m => m.GetOpportunityResponses(opportunityId, It.IsAny<string>()))
                .Returns(opportunity.Responses);

            var capacity = _fixture.OpportunityCapacity(opportunityId, eventId, opportunity.MinimumNeeded,
                opportunity.MaximumNeeded);

            Assert.IsNotNull(capacity);
            Assert.AreEqual(capacity.Display, false);
        }
        public void OpportunityCapacityHasMinHasMax(int? min, int? max, List<Response> mockResponses,
            Capacity expectedCapacity)
        {
            const int opportunityId = 9999;
            const int eventId = 1000;

            var opportunity = new Opportunity();
            opportunity.MaximumNeeded = max;
            opportunity.MinimumNeeded = min;
            opportunity.OpportunityId = opportunityId;
            opportunity.Responses = mockResponses;

            _opportunityService.Setup(m => m.GetOpportunityResponses(opportunityId, It.IsAny<string>()))
                .Returns(opportunity.Responses);

            var capacity = _fixture.OpportunityCapacity(opportunityId, eventId, min, max);

            Assert.IsNotNull(capacity);
            Assert.AreEqual(capacity.Available, expectedCapacity.Available);
            Assert.AreEqual(capacity.BadgeType, expectedCapacity.BadgeType);
            Assert.AreEqual(capacity.Display, expectedCapacity.Display);
            Assert.AreEqual(capacity.Maximum, expectedCapacity.Maximum);
            Assert.AreEqual(capacity.Message, expectedCapacity.Message);
            Assert.AreEqual(capacity.Minimum, expectedCapacity.Minimum);
            Assert.AreEqual(capacity.Taken, expectedCapacity.Taken);
        }