public static AuditReviewTrackingViewModel StatementReviewsFrom(StatementReviews source, IDictionary <byte, string> messageIDs)
 {
     return(source == null ? new AuditReviewTrackingViewModel() : new AuditReviewTrackingViewModel
     {
         Reviews = (from r in source.Reviews
                    group r by r.CommitteeID).ToDictionary(g => g.Key, g => g.Select(r => AuditReviewFrom(r, messageIDs.ContainsKey(r.Number) ? messageIDs[r.Number] : null, r.Statement))),
         CommiteeNames = GetNamesFrom(source.Reviews)
     });
 }
Exemple #2
0
        /// <summary>
        /// Retrieves a collection of all statement reviews from a <see cref="StatementReviewTds"/> dataset.
        /// </summary>
        /// <param name="ds">The dataset to read.</param>
        /// <param name="electionCycle">The election cycle pertaining to the dataset.</param>
        /// <returns>A collection of all statement reviews in the dataset.</returns>
        private StatementReviews ReadStatmentReviews(StatementReviewTds ds, string electionCycle)
        {
            Election         election = GetElections(CPProviders.SettingsProvider.MinimumElectionCycle)[electionCycle];
            StatementReviews sr       = new StatementReviews();

            if (election == null)
            {
                return(sr);
            }
            var s = this.GetStatements(electionCycle);

            foreach (StatementReviewTds.StatementReviewsRow row in ds.StatementReviews.Rows)
            {
                //fetch applicable dates and create a new StatementReview object as appropriate
                byte number = row.StatementNumber;
                if (!object.Equals(s, null) && s.ContainsKey(number))
                {
                    StatementReview review = new StatementReview(row.ElectionCycle.Trim(), ParseCommitteeID(row.CommitteeID), s[number])
                    {
                        StartDate     = row.IsStartDateNull() ? DateTime.MinValue : row.StartDate,
                        EndDate       = row.IsCompletionDateNull() ? DateTime.MinValue : row.CompletionDate,
                        LastUpdated   = row.LastUpdated,
                        SentDate      = row.IsSentDateNull() ? null : row.SentDate as DateTime?,
                        CommitteeName = row.CommitteeName.Trim()
                    };
                    // response due only if due date is after letter sent date
                    if (!row.IsResponseDueDateNull() && review.SentDate.HasValue && (review.SentDate.Value < row.ResponseDueDate))
                    {
                        SRResponseDeadline deadline = new SRResponseDeadline(row.ResponseDueDate.Date, review);
                        if (!row.IsResponseReceivedDateNull())
                        {
                            deadline.ResponseReceivedDate = row.ResponseReceivedDate;
                        }
                        if (!row.IsExtensionDueDateNull())
                        {
                            deadline.GrantExtension(row.ExtensionDueDate.Date, null, Convert.ToUInt16(row.ExtensionsCount));
                        }
                        review.ResponseDeadline = deadline;
                        sr.ResponseDeadlines.Add(deadline);
                    }
                    sr.Reviews.Add(review);
                }
            }
            return(sr);
        }