//Take in all of the destination data from Scraper and load into a list of skyscanner URL's to scrape //any number of destinations can be loaded from database without having to change this method //which means the method for scraping data will never have to change, only the database public List <FlightUrl> LoadDestinationsToScrape(string connectionString) { List <FlightUrl> destinations = new List <FlightUrl>(); try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(SQL_LoadDestinations, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < 6; i++) { //six day trips (4 full days, 2 days travel) FlightUrl f = new FlightUrl(); f.DestinationAirportCode = Convert.ToString(reader["airport_code"]); f.LocationName = Convert.ToString(reader["name"]); f.LocationId = Convert.ToInt32(reader["location_id"]); f.SkyScannerDomainName = "https://www.skyscanner.com/transport/flights/lax/"; f.DepartureDate = DateAndTime.GetDepartureDate().AddDays(i).ToString("/yyMMdd/"); f.ReturnDate = DateAndTime.GetReturnDate().AddDays(i).ToString("yyMMdd"); f.SkyScannerVariables = "?adults=1&children=0&adultsv2=1&childrenv2=&infants=0&" + "cabinclass=economy&rtn=1&preferdirects=false&" + "outboundaltsenabled=false&inboundaltsenabled=false&ref=home#results"; f.Depart = DateAndTime.GetDepartureDate().AddDays(i); f.Return = DateAndTime.GetReturnDate().AddDays(i); destinations.Add(f); //seven day trips (5 full days, 2 days travel) FlightUrl f2 = new FlightUrl(); f2.DestinationAirportCode = Convert.ToString(reader["airport_code"]); f2.LocationName = Convert.ToString(reader["name"]); f2.LocationId = Convert.ToInt32(reader["location_id"]); f2.SkyScannerDomainName = "https://www.skyscanner.com/transport/flights/lax/"; f2.DepartureDate = DateAndTime.GetDepartureDate().AddDays(i).ToString("/yyMMdd/"); f2.ReturnDate = DateAndTime.GetReturnDate().AddDays(i + 1).ToString("yyMMdd"); f2.SkyScannerVariables = "?adults=1&children=0&adultsv2=1&childrenv2=&infants=0&" + "cabinclass=economy&rtn=1&preferdirects=false&" + "outboundaltsenabled=false&inboundaltsenabled=false&ref=home#results"; f2.Depart = DateAndTime.GetDepartureDate().AddDays(i); f2.Return = DateAndTime.GetReturnDate().AddDays(i + 1); destinations.Add(f2); } } } } catch (SqlException e) { Email.SendEmailFailure(e.ToString(), "Failed during: public List<FlightUrl> LoadDestinationsToScrape()"); throw; } return(destinations); }