示例#1
0
 private static PublicFundsViewModel PublicFundsPaymentFrom(PublicFundsDetermination source)
 {
     return(source == null ? new PublicFundsViewModel() : new PublicFundsViewModel
     {
         Amount = source.PaymentIssued ? (decimal?)source.PaymentAmount : null,
         Date = source.Date,
         ElectionType = source.ElectionType,
         MessageID = source.MessageID,
         Method = source.PaymentIssued ? (PaymentMethod?)source.PaymentMethod : null
     });
 }
        public void ItemTest()
        {
            int capacity = 0;                                             // TODO: Initialize to an appropriate value
            PublicFundsHistory target = new PublicFundsHistory(capacity); // TODO: Initialize to an appropriate value
            int index = 0;                                                // TODO: Initialize to an appropriate value
            PublicFundsDetermination expected = null;                     // TODO: Initialize to an appropriate value
            PublicFundsDetermination actual;

            target[index] = expected;
            actual        = target[index];
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#3
0
        /// <summary>
        /// Retrieves a history of public funds determinations for a specific candidate and election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose public funds determination history is to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>A history of public funds determinations for the specified candidate and election cycle.</returns>
        public PublicFundsHistory GetPublicFundsHistory(string candidateID, string electionCycle)
        {
            // retrieve CMO message IDs
            using (Data.CmoEntities context = new Data.CmoEntities())
            {
                var messages = from m in context.CmoMessages
                               join p in context.CmoAuditReviews
                               on new { m.CandidateId, m.MessageId } equals new { p.CandidateId, p.MessageId }
                where m.CandidateId == candidateID && m.ElectionCycle == electionCycle && m.PostDate.HasValue
                group p by p.ReviewNumber into pgroup
                select new { Run = pgroup.Key, MessageID = pgroup.Max(p => p.MessageId) };

                // retrieve payment records
                using (PaymentPlanTds ds = new PaymentPlanTds())
                {
                    PaymentPlanTds.PublicFundsHistoryDataTable table = ds.PublicFundsHistory;
                    using (PublicFundsHistoryTableAdapter ta = new PublicFundsHistoryTableAdapter())
                    {
                        ta.Fill(table, candidateID, electionCycle);
                    }
                    PublicFundsHistory history = new PublicFundsHistory(table.Count);
                    foreach (PaymentPlanTds.PublicFundsHistoryRow row in table)
                    {
                        PublicFundsDetermination payment = new PublicFundsDetermination(row.Date, row.Amount > 0)
                        {
                            ElectionType  = CPConvert.ToElectionType(row.ElectionTypeCode.Trim()),
                            PaymentAmount = row.Amount,
                            PaymentMethod = string.IsNullOrEmpty(row.CheckNumber.Trim()) ? PaymentMethod.Eft : PaymentMethod.Check,
                            Run           = row.Run
                        };
                        // associate message ID if found
                        var message = messages.FirstOrDefault(m => m.Run == row.Run);
                        if (message != null)
                        {
                            payment.MessageID = message.MessageID;
                        }
                        history.Determinations.Add(payment);
                    }
                    return(history);
                }
            }
        }