Exemplo n.º 1
0
        private static Donation GetDonationFromMap(Dictionary<int, Donation> donationMap,
                                            Dictionary<string, Object> record,
                                            int donationId,
                                            List<DonationStatus> statuses)
        {
            if (donationMap.ContainsKey(donationId))
            {
                return donationMap[donationId];
            }
            
            var donation = new Donation
            {
                donationDate = record["Donation_Date"] as DateTime? ?? DateTime.Now,
                batchId = null,
                donationId = record["Donation_ID"] as int? ?? 0,
                donationNotes = null,
                donationStatus = record["Donation_Status_ID"] as int? ?? 0,
                donationStatusDate = record["Donation_Status_Date"] as DateTime? ?? DateTime.Now,
                donorId = record["Donor_ID"] as int? ?? 0,
                paymentTypeId = record["Payment_Type_ID"] as int? ?? 0,
                transactionCode = record["Transaction_Code"] as string,
                softCreditDonorId = record["Soft_Credit_Donor_ID"] as int? ?? 0,
                donorDisplayName = record["Donor_Display_Name"] as string,
            };

            var status = statuses.Find(x => x.Id == donation.donationStatus) ?? new DonationStatus();
            donation.IncludeOnGivingHistory = status.DisplayOnGivingHistory;
            donation.IncludeOnPrintedStatement = status.DisplayOnStatement;

            return donation;
        }
Exemplo n.º 2
0
        private static void AddDistributionToDonation(Dictionary<string, Object> record, Donation donation)
        {

            var amount = Convert.ToInt32((record["Amount"] as decimal? ?? 0) * Constants.StripeDecimalConversionValue);
            donation.donationAmt += amount;

            donation.Distributions.Add(new DonationDistribution
            {
                donationDistributionProgram = record["dp_RecordName"] as string,
                donationDistributionAmt = amount
            });
        }
Exemplo n.º 3
0
        private Donation GetDonationByProcessorPaymentId(string processorPaymentId, string apiToken)
        {
            var result = _ministryPlatformService.GetRecordsDict(_donationsPageId, apiToken,
                ",,,,,,," + processorPaymentId);
          
            if (result.Count == 0 || (result.Last().ToNullableInt("dp_RecordID")) == null)
            {
                throw (new ApplicationException("Could not locate donation for charge " + processorPaymentId));
            }

            var dictionary = result.First();
          
            var d = new Donation()
            {
                donationId = dictionary.ToInt("dp_RecordID"),
                donorId = dictionary.ToInt("Donor_ID"),
                donationDate = dictionary.ToDate("Donation_Date"),
                donationAmt = Convert.ToInt32(dictionary["Donation_Amount"]),
                paymentTypeId = PaymentType.GetPaymentType(dictionary.ToString("Payment_Type")).id,
                donationNotes = dictionary.ToString("Donation_Status_Notes"),
                batchId = dictionary.ToNullableInt("Batch_ID")
            };
            return (d);
        }