Esempio n. 1
0
        public async Task <IActionResult> GetFlights([FromQuery] FlightParameters parameters)
        {
            var flights = await _flightRepository.GetFlights(parameters);

            if (flights == null || !flights.Any())
            {
                return(BadRequest("Could not find any flights"));
            }

            Response.AddPaginationHeader(flights.CurrentPage, flights.PageSize, flights.TotalCount, flights.TotalPages);

            return(Ok(flights));
        }
        public async Task <PagedList <FlightForListDto> > GetFlights(FlightParameters parameters)
        {
            try
            {
                var flights = _context.Flights.Where(x => x.DateOfArrival > DateTime.UtcNow)
                              .OrderBy(x => x.DateOfDeparture)
                              .Include(x => x.Origin)
                              .Include(x => x.Destination)
                              .ProjectTo <FlightForListDto>(_mapper.ConfigurationProvider)
                              .AsNoTracking();

                return(await PagedList <FlightForListDto> .CreateAsync(flights, parameters.PageNumber,
                                                                       parameters.PageSize));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Esempio n. 3
0
 protected override float getCurrentValue()
 {
     return(FlightParameters.get().PID_P);
 }
Esempio n. 4
0
 protected override void increateValue(float pValue)
 {
     FlightParameters.get().PID_P += pValue;
 }
Esempio n. 5
0
 private string getPIDValues()
 {
     return(String.Format(@"P: {0}, I: {1}, D: {2}", FlightParameters.get().PID_P, FlightParameters.get().PID_I, FlightParameters.get().PID_D));
 }