/// <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();
 }
        /// <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();
        }
 public Checkpoint GetCheckpoint(int serial)
 {
     return(Checkpoints.FirstOrDefault(cp => cp.Serial == serial));
 }