public Reservation GetReservationById(int id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Reservations.Where(x => x.Reservation_id == id).FirstOrDefault());
     }
 }
 public List <Reservation> GetAllReservation()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Reservations.ToList());
     }
 }
 public Airport GetAirportById(int id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.Where(x => x.Airport_id == id).FirstOrDefault());
     }
 }
 public void DeleteFlight(Flight flight)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Flight>().Remove(flight);
     }
 }
 public List <Airport> GetAllAirport()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.ToList());
     }
 }
 public List <Flight> GetAllFlight()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Flights.ToList());
     }
 }
 public string GetAllAirportNames()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.FirstOrDefault().Name);
     }
 }
 public Flight GetFlightById(string id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Flights.Where(x => x.Flight_id == id).FirstOrDefault());
     }
 }
 public void UpdateFlight(Flight entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Entry <Flight>(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public int CreateReservation(Reservation entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Reservation>().Add(entity);
         db.SaveChanges();
     }
     return(entity.Reservation_id);
 }
 public string CreateFlight(Flight entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Flight>().Add(entity);
         db.SaveChanges();
     }
     return(entity.Flight_id);
 }
        public List <double> GetCoordinate(string Airport)
        {
            using (FlightReservationEntities db = new FlightReservationEntities())
            {
                var Query = from a in db.Airports
                            where a.Name == Airport
                            select new { a.Latitude, a.Longitude };
                List <double> Coordinates = new List <double>();

                foreach (var res in Query)
                {
                    Coordinates.Add(res.Latitude);
                    Coordinates.Add(res.Longitude);
                }
                return(Coordinates);
            }
        }