public async void DeleteFlight()
 {
     if (await service.DeleteEntity(SelectedFlight.Id))
     {
         Flights.Remove(Flights.FirstOrDefault(c => c.Id == SelectedFlight.Id));
     }
 }
Exemplo n.º 2
0
        public override async Task InitializeAsync(object navigationData)
        {
            if (navigationData as ObservableCollection <Flight> != null)
            {
                var flights = (ObservableCollection <Flight>)navigationData;
                Profile = await _authenticationService.GetProfileAsync();

                foreach (var flight in flights)
                {
                    flight.PassengerName = Profile.Name;
                }

                Flights = flights;
                var departure = Flights.FirstOrDefault();

                if (departure != null)
                {
                    FromName = departure.FromName;
                    FromCode = departure.FromCode;
                }

                var arrival = Flights.LastOrDefault();

                if (arrival != null)
                {
                    ToName = arrival.ToName;
                    ToCode = arrival.ToCode;
                }
            }
        }
 public async void UpdateFlight()
 {
     if (await service.UpdateEntity(SelectedFlight.Id, SelectedFlight))
     {
         var tempFlight = Flights.FirstOrDefault(c => c.Id == SelectedFlight.Id);
         tempFlight.DeparturePoint  = SelectedFlight.DeparturePoint;
         tempFlight.DepartureTime   = SelectedFlight.DepartureTime;
         tempFlight.Destination     = SelectedFlight.Destination;
         tempFlight.DestinationTime = SelectedFlight.DestinationTime;
         tempFlight.Number          = SelectedFlight.Number;
         tempFlight.Tickets         = SelectedFlight.Tickets;
     }
 }
        public async Task <ActionResult> OnGetAsync()
        {
            Sessions = await Client.GetSessionsAsync();

            Flights = await Client.GetFlightsAsync(Sessions.FirstOrDefault().Id);

            FlightPlans = await Client.GetFlightPlansAsync(Sessions.FirstOrDefault().Id);

            AtcFacilities = await Client.GetAtcFacilitiesAsync(new Guid("7e5dcd44-1fb5-49cc-bc2c-a9aab1f6a856"));

            User = await Client.GetUserGradeAsync(Flights.FirstOrDefault().UserId);

            return(Page());
        }
Exemplo n.º 5
0
        public bool DisposeFlight(int flightSerial)
        {
            Flight toRemove = Flights.FirstOrDefault(f => f.FlightSerial == flightSerial);

            try
            {
                Flights.Remove(toRemove);
                SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Updates the checkpoints the current flight passes between
 /// </summary>
 /// <param name="newCheckpointSerial">the next checkpoint's serial</param>
 /// <param name="lastCheckpointSerial">the last checkpoint's serial</param>
 /// <param name="flight">the current flight</param>
 public void UpdateCheckpoint(int newCheckpointSerial, int lastCheckpointSerial, Flight flight)
 {
     //if the last checkpoint's serial is 8, it's the depart checkpoint
     if (lastCheckpointSerial == 8)
     {
         Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
             Checkpoints.FirstOrDefault(cp => cp.CheckpointType == CheckpointType.RunwayDeparting.ToString());
     }
     //all other checkpoints will be updated by the new checkpoint serial
     else
     {
         Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
             Checkpoints.FirstOrDefault(cp => cp.Serial == newCheckpointSerial);
     }
     SaveChanges();
 }
Exemplo n.º 7
0
        internal bool DeleteFlight(long id)
        {
            Flight f = Flights.FirstOrDefault(f => f.FlightId == id);

            try
            {
                Flights.Remove(f);
            }
            catch (NullReferenceException e)
            {
                throw e;
            }

            this.SaveChanges();

            return(true);
        }
Exemplo n.º 8
0
        public void CloseLane(int laneId)
        {
            ScannerFlight l2fObj = null;

            using (var ds = new DataSeed()) {
                l2fObj = ScannerFlights.FirstOrDefault(p => p.LaneId == laneId);
                if (l2fObj == null)
                {
                    return;
                }
                ds.CloseLane(l2fObj.Flight2LaneId);
                ScannerFlights.Remove(l2fObj);
                if (ScannerFlights.Where(s => s.FlightId == l2fObj.FlightId).Count() == 0)
                {
                    ds.ChangeFlightStatus(l2fObj.FlightId, (int)Enums.FlightStatus.Closed);
                    CloseFlightId = l2fObj.FlightId;
                    Flights.FirstOrDefault(f => f.Id == l2fObj.FlightId).StatusId = 2;
                }
                CloseLaneStatus = "The " + Lanes.FirstOrDefault(p => p.Id == laneId)?.Color + " Lane from Flight " + l2fObj.FlightNumber + " was closed.";
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Updates the current flight' checkpoint
        /// </summary>
        /// <param name="flight">the current flight</param>
        /// <param name="newCheckpointSerial">the next checkpoint's serial</param>
        /// <param name="lastCheckpointSerial">the last checkpoint's serial</param>
        /// <param name="isNew">indicates if the flight is not alive</param>
        public void UpdateFlight(Flight flight, int newCheckpointSerial, int lastCheckpointSerial, bool isNew)
        {
            //if the flight is new, it's alive state is modified
            if (isNew)
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).IsAlive = true;
            }

            //f the last checkpoint's serial is 8, it's the depart checkpoint
            if (lastCheckpointSerial == 8)
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
                    Checkpoints.FirstOrDefault(cp => cp.CheckpointType == CheckpointType.RunwayDeparting.ToString());
            }
            //all other checkpoints will be updated by the new checkpoint serial
            else
            {
                Flights.FirstOrDefault(f => f.FlightSerial == flight.FlightSerial).Checkpoint =
                    Checkpoints.FirstOrDefault(cp => cp.Serial == newCheckpointSerial);
            }
            SaveChanges();
        }
Exemplo n.º 10
0
        private static void DeleteFlight(string flightNumber)
        {
            var flight = Flights.FirstOrDefault(x => x.FlightNumber == flightNumber);

            if (flight == null)
            {
                MessageBox.Show("Flight could not be found!");
                return;
            }

            Flights.Remove(flight);

            switch (flight.FlightState)
            {
            case FlightState.Incoming:
                IncomingFlights.Remove(flight);
                break;

            case FlightState.WaitingForPreparation:
                OutgoingFlights.Remove(flight);
                break;
            }
        }
Exemplo n.º 11
0
        public string RemoveCard(List <int> cardId, out int flightId)
        {
            string message = null;

            flightId = 0;
            int  l2fId;
            bool isHasParentOtherStudent;

            using (var ds = new DataSeed()) {
                if (LaneLogistic == ScannerType.SingleScanner && curentLaneId == 0)
                {
                    if (!isMoveRemoveCard)
                    {
                        currentLaneNumber = currentLaneNumber <= 0 ? (Lanes.Count() - 1) : (currentLaneNumber - 1);
                    }
                    else
                    {
                        isMoveRemoveCard = false;
                    }
                }
                message = ds.RemoveDissmisalCard(cardId, out l2fId, out isHasParentOtherStudent);
            };

            if (l2fId != 0)
            {
                var objL2F = ScannerFlights.FirstOrDefault(p => p.Flight2LaneId == l2fId);
                if (objL2F != null)
                {
                    if (!isHasParentOtherStudent)
                    {
                        objL2F.CountCarsInLane -= 1;
                    }
                }

                if (IsFlightEmpty(objL2F.FlightId))
                {
                    int  flId     = objL2F.FlightId;
                    bool isDelete = false;
                    using (var ds = new DataSeed())
                    {
                        isDelete = ds.DeleteFlightById(flId);
                    }
                    if (isDelete)
                    {
                        FlightNumber--;
                        for (int i = 0; i < ScannerFlights.Count(); i++)
                        {
                            if (ScannerFlights[i].FlightId == flId)
                            {
                                ScannerFlights.RemoveAt(i);
                                i--;
                            }
                        }
                        Flight flight = Flights.FirstOrDefault(f => f.Id == flId);
                        Flights.Remove(flight);
                        flightId = flId;
                    }
                }
            }
            return(message);
        }
Exemplo n.º 12
0
 internal Flight GetFlight(long id)
 {
     return(Flights.FirstOrDefault(f => f.FlightId == id));
 }
Exemplo n.º 13
0
 public Flight GetFlight(int flightSerial)
 {
     return(Flights.FirstOrDefault(f => f.FlightSerial == flightSerial));
 }