Example #1
0
        public async Task RepositoryClubAircrafFlightTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                cr       = new ClubRepository(_context);
                AircraftLogBookRepository acr             = new AircraftLogBookRepository(_context);
                FlightRepository          fr              = new FlightRepository(_context);
                MemberRepository          mr              = new MemberRepository(_context);
                ClubRepository            _clubRepository = new ClubRepository(_context);
                AircraftRepository        ar              = new AircraftRepository(_context);
                ClubService clubService = new ClubService(cr, mr, fr, ar, acr, null);
                int         aircraftId  = 8;
                var         clubSpec    = new ClubWithSpecification("BAZ", false, true);

                var club = (await _clubRepository.ListAsync(clubSpec));
                FlighWithSpecification flightPagingSpec = new FlighWithSpecification(0, 10, 8, 14);
                FlighWithSpecification flightSpec       = new FlighWithSpecification(8, 14);

                var flight = await fr.ListAsync(flightPagingSpec);

                var flightCount = await fr.CountAsync(flightSpec);

                ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId);

                var group = flights.GroupBy(o => o.Pilot);
                foreach (var g in group)
                {
                    System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName);
                    foreach (var gi in g)
                    {
                        System.Diagnostics.Debug.WriteLine(gi.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }