コード例 #1
0
 public Reservation GetReservationById(int id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Reservations.Where(x => x.Reservation_id == id).FirstOrDefault());
     }
 }
コード例 #2
0
 public List <Reservation> GetAllReservation()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Reservations.ToList());
     }
 }
コード例 #3
0
 public Airport GetAirportById(int id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.Where(x => x.Airport_id == id).FirstOrDefault());
     }
 }
コード例 #4
0
 public void DeleteFlight(Flight flight)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Flight>().Remove(flight);
     }
 }
コード例 #5
0
 public List <Airport> GetAllAirport()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.ToList());
     }
 }
コード例 #6
0
 public List <Flight> GetAllFlight()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Flights.ToList());
     }
 }
コード例 #7
0
 public string GetAllAirportNames()
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Airports.FirstOrDefault().Name);
     }
 }
コード例 #8
0
 public Flight GetFlightById(string id)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         return(db.Flights.Where(x => x.Flight_id == id).FirstOrDefault());
     }
 }
コード例 #9
0
 public void UpdateFlight(Flight entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Entry <Flight>(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
コード例 #10
0
 public int CreateReservation(Reservation entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Reservation>().Add(entity);
         db.SaveChanges();
     }
     return(entity.Reservation_id);
 }
コード例 #11
0
 public string CreateFlight(Flight entity)
 {
     using (FlightReservationEntities db = new FlightReservationEntities())
     {
         db.Set <Flight>().Add(entity);
         db.SaveChanges();
     }
     return(entity.Flight_id);
 }
コード例 #12
0
        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);
            }
        }