public void GetAListOfFilteredByFatalCyclingAccidentsAndSortedByIdAscending()
        {
            var actual = _subject.Get(filter =>
                                      filter.Severity == Severity.Fatal &&
                                      filter.Casualties.Any(casualty =>
                                                            casualty.Mode.Equals("PedalCycle") &&
                                                            casualty.Severity == Severity.Fatal),
                                      OrderBy(x => x.AccidentStatisticId, true))
                         .GetAwaiter()
                         .GetResult();

            Approvals.VerifyJson(actual.ToJson());
        }
Example #2
0
        private static async Task LoadAllCyclingAccidents(AccidentStatisticDbContext accidentStatisticDbContext,
                                                          DateTime from, DateTime to, ILogger logger)
        {
            var repository = new AccidentStatisticRepository(accidentStatisticDbContext);
            int?nextPage   = 1;

            do
            {
                var result = await repository.Get(filter =>
                                                  filter.Date >= from && filter.Date <= to &&
                                                  filter.Severity == Severity.Fatal &&
                                                  filter.Casualties.Any(casualty =>
                                                                        casualty.Mode.Equals("PedalCycle") && casualty.Severity == Severity.Fatal),
                                                  OrderBy(x => x.Borough, false),
                                                  nextPage.Value);

                logger.Information($"Displaying Page {nextPage} returning '{result.PageSize}' records of '{result.Total}' cycling fatalities in total from {from.ToLongDateString()} to {to.ToLongDateString()} ...");
                foreach (var cyclingAccident in result.Data)
                {
                    logger.Information($"Cycling accident occured in the borough of {cyclingAccident.Borough.ToUpper()} involving '{cyclingAccident.Casualties.Count}' casualties and '{cyclingAccident.Vehicles.Count}' vehicles.");
                }
                nextPage = result.NextPage;
            } while (nextPage.HasValue);
        }