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(); } }
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."); } } }
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"); } } }
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"); } } }
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); } }