예제 #1
0
 public List <Flight> ViewAllFlights()
 {
     using (FlightContext context = new FlightContext())
     {
         return(context.Flights.ToList());
     }
 }
예제 #2
0
        public List <Flight> SearchFlightByDestination(string destination)
        {
            if (!(string.IsNullOrEmpty(destination)))
            {
                destination = validation.StringValidation(destination);

                using (FlightContext context = new FlightContext())
                {
                    var SrchResult =
                        (from a in context.Flights
                         where (a.FlightCity == destination)
                         & (a.Flightdate > DateTime.Today.Date)
                         & (a.DepartureOrArrival)
                         orderby a.Flightdate descending
                         select a)
                        .Take(50)
                        .ToList();
                    return(SrchResult);
                }
            }
            else
            {
                return(new List <Flight>());
            }
        }
예제 #3
0
 public Flight SearchFlight(int?id)
 {
     using (FlightContext context = new FlightContext())
     {
         var flight = context.Flights.SingleOrDefault(a => a.FlightId == id);
         return(flight);
     }
 }
예제 #4
0
 public List <Flight> ViewArrivalFlights()
 {
     using (FlightContext context = new FlightContext())
     {
         var SrchResult =
             (from a in context.Flights
              where (a.DepartureOrArrival == false)
              orderby a.Flightdate descending
              select a).Take(50)
             .ToList();
         return(SrchResult);
     }
 }
예제 #5
0
        //Departure Flights have DepartureOrArrival - true, Arrival - false
        public List <Flight> SearchFlights(string searchData)
        {
            if (!(string.IsNullOrEmpty(searchData)))
            {
                searchData = validation.StringValidation(searchData);
                using (FlightContext context = new FlightContext())
                {
                    var SrchResult =
                        (from a in context.Flights
                         where (a.FlightNum == searchData || a.FlightCity == searchData)
                         select a)
                        .ToList();
                    return(SrchResult);
                }
            }

            return(null);
        }
예제 #6
0
        public List <Flight> SearchArrivalFlights(string searchData)
        {
            if (!(string.IsNullOrEmpty(searchData)))
            {
                searchData = validation.StringValidation(searchData);

                using (FlightContext context = new FlightContext())
                {
                    var SrchResult =
                        (from a in context.Flights
                         where (a.FlightNum == searchData || a.FlightCity == searchData)
                         where (a.DepartureOrArrival == false)
                         select a)
                        .ToList();
                    return(SrchResult);
                }
            }
            else
            {
                return(new List <Flight>());
            }
        }
예제 #7
0
 public List <Passenger> AdminPassSearch(string searchData)
 {
     if (!(string.IsNullOrEmpty(searchData)))
     {
         searchData = validation.StringValidation(searchData);
         using (FlightContext context = new FlightContext())
         {
             var SrchResult =
                 (from a in context.Passengers
                  where (a.FirstName == searchData || a.LastName == searchData || a.Passport == searchData)
                  orderby a.FlightId descending
                  select a)
                 .Take(50)
                 .ToList();
             return(SrchResult);
         }
     }
     else
     {
         return(null);
     }
 }
예제 #8
0
 public List <Flight> AdminFlightsSearch(string searchData)
 {
     if (!(string.IsNullOrEmpty(searchData)))
     {
         searchData = validation.StringValidation(searchData);
         var newData = validation.IntConvert(searchData);
         using (FlightContext context = new FlightContext())
         {
             var SrchResult =
                 (from a in context.Flights
                  where (a.FlightNum == searchData || a.FlightCity == searchData || a.FlightId == newData)
                  orderby a.Flightdate descending
                  select a).
                 Take(50)
                 .ToList();
             return(SrchResult);
         }
     }
     else
     {
         return(new List <Flight>());
     }
 }
예제 #9
0
        public List <Flight> SearchFlightByPrice(string lowPrice, string upPrice)
        {
            if (!(string.IsNullOrEmpty(lowPrice) && (string.IsNullOrEmpty(upPrice))))
            {
                int.TryParse(lowPrice, out int intLowPrice);
                int.TryParse(upPrice, out int intUpPrice);

                using (FlightContext context = new FlightContext())
                {
                    var SrchResult =
                        (from a in context.Flights
                         where (a.BusinessPrice >= intLowPrice && a.BusinessPrice <= intUpPrice) ||
                         (a.EconomPrice <= intUpPrice && a.EconomPrice >= intLowPrice)
                         & (a.Flightdate > DateTime.Today.Date)
                         & (a.DepartureOrArrival)
                         orderby a.Flightdate descending
                         select a)
                        .Take(50)
                        .ToList();
                    return(SrchResult);
                }
            }
            return(new List <Flight>());
        }