private static void PopulateDateStatistics(TreeStatistics treeStatistics, List <WhoWhatWhereWhen> whoWhatWhereWhen) { var peopleGrouped = whoWhatWhereWhen .GroupBy(g => g.Who.Id) .ToList(); treeStatistics.PeopleNotFound = !peopleGrouped.Any(); treeStatistics.NumberOfPeople = peopleGrouped.Count(); var allDates = whoWhatWhereWhen .Select(p => p.When.DateRange) .ToList(); var dateStatusEnums = Enum.GetValues(typeof(DateQualityStatus)); foreach (DateQualityStatus dateEnumStatus in dateStatusEnums) { var dateSummary = new DateSummary { Count = allDates.Count(d => d.Status == dateEnumStatus), Status = dateEnumStatus, }; treeStatistics.DateCountsByStatus.Add(dateSummary); } treeStatistics.DateIssuesExist = treeStatistics .DateCountsByStatus .Where(d => d.Status != DateQualityStatus.OK) .Any(d => d.Count > 0); }
private static ConsoleColor ColourForDateSummary(DateSummary dateSummary) { if (dateSummary.Status == DateQualityStatus.OK && dateSummary.Count == 0) { return(ConsoleColor.Yellow); } else if (dateSummary.Status == DateQualityStatus.MonthIsAmbiguous && dateSummary.Count > 0) { return(ConsoleColor.Yellow); } else if (dateSummary.Status == DateQualityStatus.Empty && dateSummary.Count > 0) { return(ConsoleColor.Yellow); } else if (dateSummary.Status != DateQualityStatus.OK && dateSummary.Count > 0) { return(ConsoleColor.Red); } return(ConsoleColor.Green); }