Пример #1
0
        public FlightListPage()
        {
            this.flightListViewModel = new FlightListViewModel();
            this.BindingContext      = this.flightListViewModel;

            InitializeComponent();
        }
Пример #2
0
        public IActionResult Index(FlightListViewModel model)
        {
            model.Pager              = model.Pager ?? new Models.PagerViewModel();
            model.Pager.CurrentPage  = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage;
            model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage;

            model.Filter = model.Filter ?? new Models.Filters.FlightsFilterViewModel();

            bool emptyDepartureCity = string.IsNullOrWhiteSpace(model.Filter.DepartureCity);
            bool emptyArrivalCity   = string.IsNullOrWhiteSpace(model.Filter.ArrivalCity);


            IQueryable <Flight> flights = _flightRepository.Items.Where(
                item => (emptyDepartureCity || item.DepartureCity.Contains(model.Filter.DepartureCity)) &&
                (emptyArrivalCity || item.ArrivalCity.Contains(model.Filter.ArrivalCity)));

            model.Pager.Pages = (int)Math.Ceiling((double)flights.Count() / model.Pager.ItemsPerPage);


            flights = flights.OrderBy(item => item.Id)
                      .Skip((model.Pager.CurrentPage - 1) * model.Pager.ItemsPerPage)
                      .Take(model.Pager.ItemsPerPage);
            flights     = flights.Where(item => item.DepartureTime > DateTime.Now && item.CapacityEconomyPassengers != 0 && item.CapacityBusinessPassengers != 0);
            model.Items = _mapper.Map <ICollection <FlightViewModel> >(flights).AsQueryable();
            return(View(model));
        }
Пример #3
0
        public IActionResult List()
        {
            var viewModel = new FlightListViewModel {
                FlightsList = new List <FlightViewModel>()
            };

            foreach (var item in _flightRepository.GetAllFlights())
            {
                item.InternalId = item.Id.ToString();
                viewModel.FlightsList.Add(new FlightViewModel {
                    Flight = item, IsEdit = true
                });
            }
            return(View(viewModel));
        }
        public async Task <IActionResult> Index()
        {
            var flights = await flightsClient.GetFlightsAsync().ConfigureAwait(true);

            var flightListViewModel = new FlightListViewModel
            {
                Flights = flights
                          .Select(f => new FlightViewModel
                {
                    Id     = f.Id,
                    Number = f.Number,
                    Date   = f.Date.ToShortDateString()
                })
                          .ToArray()
            };

            return(View(flightListViewModel));
        }
        public async Task <IActionResult> Index(FlightListViewModel model)
        {
            List <SingleFlightViewModel> items = await _context.Flights.Select(f => new SingleFlightViewModel()
            {
                Id        = f.Id,
                From      = f.From,
                To        = f.To,
                TakeOff   = f.TakeOff,
                Landing   = f.Landing,
                TypePlane = f.TypePlane,
                PlaneId   = f.PlaneId,
                PilotName = f.PilotName,
                AvailablePassengerSeats     = f.AvailablePassengerSeats,
                AvailableBusinessClassSeats = f.AvailableBusinessClassSeats
            }).ToListAsync();

            model.Flights = items;
            return(View(model));
        }
Пример #6
0
        public JsonFlightlist MyflightList()
        {
            JsonFlightlist             jsonFlightlist = new JsonFlightlist();
            List <FlightListViewModel> flightlistOBJ  = new List <FlightListViewModel>();

            try
            {
                string Custumerid = User.Claims.First(u => u.Type == "Customer").Value;
                var    Userobj    = _customer.FindById(Convert.ToInt32(Custumerid));
                if (Userobj != null)
                {
                    foreach (var item in _customerFlight.ToList(Userobj.Id))
                    {
                        var Flight = _flight.FindById(item.FlightId);
                        FlightListViewModel flightObj = new FlightListViewModel();
                        flightObj.FlightNumber = Flight.Number;
                        flightObj.airplainid   = Flight.FlightAirPlaneId;
                        flightObj.Airplaincode = Flight.FlightAirPlaneId;
                        flightObj.AirlineIcon  = _airline.FindById(_airPlane.FindById(Flight.FlightAirPlaneId).AirlineId).Logo;
                        flightObj.AirlineName  = _airline.FindById(_airPlane.FindById(Flight.FlightAirPlaneId).AirlineId).Name;
                        flightObj.AirlineId    = _airline.FindById(_airPlane.FindById(Flight.FlightAirPlaneId).AirlineId).Id;
                        flightObj.Flightid     = Flight.Id;
                        flightObj.StartAirPort = _city.FindById(_address.FindById(_airport.FindById(Flight.StartAirPortId).AirPortAddressId).CityId).Name;
                        flightObj.EndAirPort   = _city.FindById(_address.FindById(_airport.FindById(Flight.StartAirPortId).AirPortAddressId).CityId).Name;
                        flightObj.WeatherIcon  = _Weatger.FindByAirportId(Flight.StartAirPortId).Icon;
                        flightObj.StartTime    = Flight.StartTimeDate;
                        flightObj.EndTime      = Flight.EndTimeDate;
                        flightObj.Delay        = Flight.Delay;
                        flightlistOBJ.Add(flightObj);
                    }
                    jsonFlightlist.Result = flightlistOBJ;
                    return(jsonFlightlist);
                }

                return(jsonFlightlist);
            }
            catch (Exception ex)
            {
                string Mes = ex.Message;
                return(jsonFlightlist);
            }
        }
Пример #7
0
        public JsonResult Get(DateTime dt)

        {
            try
            {
                var Flights = app.FlightView.Query(x => x.DateofFlight.Date == dt.Date && x.DateofFlight.Month == dt.Month && x.DateofFlight.Year == dt.Year).ToList();
                var data    = new List <FlightListViewModel>();
                if (Flights == null)
                {
                    return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    foreach (var Flight in Flights)
                    {
                        var item = new FlightListViewModel();
                        item.AircraftID   = Flight.AircraftID;
                        item.Id           = Flight.ID;
                        item.Mode3ACode   = Flight.Mode3ACode;
                        item.SensorID     = Flight.SensorID;
                        item.DateOfFlight = Flight.DateofFlight;
                        item.FilePath     = Flight.FilePath;
                        item.CallSign     = Flight.CallSign;
                        item.TimeFrom     = Flight.TimeFrom.ToString("MM/dd/yyyy HH:mm:ss.fff ");
                        item.TimeTo       = Flight.TimeTo.ToString("MM/dd/yyyy HH:mm:ss.fff ");
                        item.CreateTime   = Flight.CreateTime;
                        item.ProcessRound = Flight.ProcessRound;
                        data.Add(item);
                    }
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }