示例#1
0
        private MyTripsDto TripForContact(int contactId)
        {
            var searchString = ",,,,,,,,,,,,," + contactId;
            var trips = _eventParticipantService.TripParticipants(searchString);

            var distributions = _donationService.GetMyTripDistributions(contactId).OrderBy(t => t.EventStartDate);
            var myTrips = new MyTripsDto();

            var events = new List<Trip>();
            var eventIds = new List<int>();
            foreach (var trip in trips.Where(trip => !eventIds.Contains(trip.EventId)))
            {
                var tripParticipant = _eventParticipantService.TripParticipants("," + trip.EventId + ",,,,,,,,,,,," + contactId).FirstOrDefault();
                if (tripParticipant == null)
                {
                    continue;
                }
                eventIds.Add(trip.EventId);

                var campaign = _mpPledgeService.GetPledgeByCampaignAndDonor(trip.CampaignId, trip.DonorId);
                if (campaign.PledgeStatusId != AppSetting("PledgeStatusDiscontinued"))
                {
                    var t = new Trip();
                    t.EventId = trip.EventId;
                    t.EventEndDate = trip.EventEndDate.ToString("MMM dd, yyyy");
                    t.EventStartDate = trip.EventStartDate.ToString("MMM dd, yyyy");
                    t.EventTitle = trip.EventTitle;
                    t.EventType = trip.EventType;
                    t.FundraisingDaysLeft = Math.Max(0, (campaign.CampaignEndDate - DateTime.Today).Days);
                    t.FundraisingGoal = Convert.ToInt32(campaign.PledgeTotal);
                    t.EventParticipantId = tripParticipant.EventParticipantId;
                    t.EventParticipantFirstName = tripParticipant.Nickname;
                    t.EventParticipantLastName = tripParticipant.Lastname;

                    events.Add(t);
                }
               
            }

            foreach (var e in events)
            {
                var donations = distributions.Where(d => d.EventId == e.EventId).OrderByDescending(d => d.DonationDate).ToList();
                foreach (var donation in donations)
                {
                    var gift = new TripGift();
                    if (donation.AnonymousGift)
                    {
                        gift.DonorNickname = "Anonymous";
                        gift.DonorLastName = "";
                    }
                    else
                    {
                        gift.DonorNickname = donation.DonorNickname ?? donation.DonorFirstName;
                        gift.DonorLastName = donation.DonorLastName;
                    }
                    gift.DonationDistributionId = donation.DonationDistributionId;
                    gift.DonorId = donation.DonorId;
                    gift.DonorEmail = donation.DonorEmail;
                    gift.DonationDate = donation.DonationDate.ToShortDateString();
                    gift.DonationAmount = donation.DonationAmount;
                    gift.PaymentTypeId = donation.PaymentTypeId;
                    gift.RegisteredDonor = donation.RegisteredDonor;
                    gift.MessageSent = donation.MessageSent;
                    gift.Anonymous = donation.AnonymousGift;
                    e.TripGifts.Add(gift);
                    e.TotalRaised += donation.DonationAmount;
                }
                myTrips.MyTrips.Add(e);
            }
            return myTrips;
        }
示例#2
0
        public MyTripsDto GetMyTrips(string token)
        {
            var family = _serveService.GetImmediateFamilyParticipants(token);
            var familyTrips = new MyTripsDto();

            foreach (var member in family)
            {
                var trips = TripForContact(member.ContactId);
                familyTrips.MyTrips.AddRange(trips.MyTrips);
            }

            return familyTrips;
        }