예제 #1
0
 public static async void CreateRange(List <Airport> airports)
 {
     using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
     {
         if (airports == null)
         {
             throw new Exception("Airport instance was not set.");
         }
         db.Airports.AddRange(airports);
         await db.SaveChangesAsync();
     }
 }
예제 #2
0
        public static async Task <bool> DeleteAll()
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                try
                {
                    db.FlightOfferSearches.RemoveRange(db.FlightOfferSearches);
                    await db.SaveChangesAsync();

                    return(true);
                }
                catch (Exception ex)
                {
                    throw new Exception("Greška kod brisanja pretraga.");
                }
            }
        }
예제 #3
0
        public async static Task <int> Create(FlightOfferSearch fos)
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                try
                {
                    db.FlightOfferSearches.Add(fos);
                    await db.SaveChangesAsync();

                    return(fos.Id);
                }
                catch (Exception ex)
                {
                    throw new Exception("Greška kod spremanja FlightOfferSearch u bazu podataka.");
                }
            }
        }
        public static async Task <int> Create(FlightOfferResult flightOfferResult)
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                try
                {
                    db.FlightOfferResults.Add(flightOfferResult);
                    await db.SaveChangesAsync();

                    return(flightOfferResult.Id);
                }
                catch
                {
                    throw new Exception("Greška kod dodavanja FlightOfferResult u bazu");
                }
            }
        }
예제 #5
0
        public static async Task <bool> DeleteAll()
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                try
                {
                    db.Airports.RemoveRange(db.Airports);
                    await db.SaveChangesAsync();

                    return(true);
                }
                catch (Exception ex)
                {
                    throw new Exception("Prvo je potrebno obrisati pretrage!");
                }
            }
        }
        public static async Task <int> Create(FlightsForOffer ffo)
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                try
                {
                    db.FlightsForOffers.Add(ffo);
                    await db.SaveChangesAsync();

                    return(ffo.Id);
                }
                catch (Exception ex)
                {
                    throw new Exception("Greška kod dodavanja FlightsForOffers u bazu");
                }
            }
        }
예제 #7
0
        public static async Task <int> Create(Airport airport)
        {
            using (AirlineTicketsDBEntities db = new AirlineTicketsDBEntities())
            {
                if (airport == null)
                {
                    throw new Exception("Airport instance was not set.");
                }
                if (db.Airports != null && db.Airports.Where(a => a.IATA == airport.IATA).Count() > 0)
                {
                    return(db.Airports.Where(a => a.IATA == airport.IATA).FirstOrDefault().Id);
                }
                db.Airports.Add(airport);
                await db.SaveChangesAsync();

                return(airport.Id);
            }
        }