public IList <LogbookEntryDisplay> CondenseFlights(IEnumerable <LogbookEntryDisplay> lstIn) { List <LogbookEntryDisplay> lstOut = new List <LogbookEntryDisplay>(); if (lstIn == null) { throw new ArgumentNullException(nameof(lstIn)); } LogbookEntryDisplay ledCurrent = null; foreach (LogbookEntryDisplay ledSrc in lstIn) { if (ledCurrent == null) { ledCurrent = ledSrc; ledSrc.FlightCount = 1; } else if (ledSrc.Date.Date.CompareTo(ledCurrent.Date.Date) != 0 || ledSrc.CatClassDisplay.CompareCurrentCultureIgnoreCase(ledCurrent.CatClassDisplay) != 0) { lstOut.Add(ledCurrent); ledCurrent = ledSrc; ledSrc.FlightCount = 1; } else { ledCurrent.AddFrom(ledSrc); List <string> lst = new List <string>() { ledCurrent.Route, ledSrc.Route }; lst.RemoveAll(sz => String.IsNullOrWhiteSpace(sz)); ledCurrent.Route = String.Join(" / ", lst); lst = new List <string>() { ledCurrent.Comment, ledSrc.Comment }; lst.RemoveAll(sz => String.IsNullOrWhiteSpace(sz)); ledCurrent.Comment = String.Join(" / ", lst); ledSrc.FlightCount++; } } if (ledCurrent != null) { lstOut.Add(ledCurrent); } return(lstOut); }
private static void ConsolidateTotals(IDictionary <string, LogbookEntryDisplay> d, LogbookEntryDisplay.LogbookRowType rowType, OptionalColumn[] optionalColumns) { if (d == null || d.Count <= 1) { return; } LogbookEntryDisplay ledAll = new LogbookEntryDisplay() { RowType = rowType, OptionalColumns = optionalColumns }; foreach (LogbookEntryDisplay led in d.Values) { ledAll.AddFrom(led); } ledAll.CatClassDisplay = Resources.LogbookEntry.PrintTotalsAllCatClass; d[Resources.LogbookEntry.PrintTotalsAllCatClass] = ledAll; }