xxxxxxxxxx
using System;
using System.Collections.Generic;
// Other using statements...
namespace Flights_DAL
{
public class Dal
{
// Constants for API endpoints and API key
private const String APIkey = "464586a1b635bd8df1683892c3b27dd6"; // <= API key
private const string allURL = @"https://data-cloud.flightradar24.com/zones/fcgi/feed.js?faa=1&bounds=41.13,29.993,25.002,36.383&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&selected=2d1e1f33&ems=1&stats=1";
private const string fLightURL = $"https://data-live.flightradar24.com/clickhandler/?version=1.5&flight=";
// Other class members...
// Constructor
public Dal()
{
// Seed the database if empty (Initialization)
FlightsDB dbContext = new FlightsDB();
SeedDataBaseIfEmpty(dbContext).GetAwaiter().GetResult();
}
// Method to seed the database with initial users if it's empty
public async Task SeedDataBaseIfEmpty(FlightsDB dbcontext)
{
// Database seeding code...
}
// Other class methods...
#region Get data using RESTful API
// Method to request data from the specified URI using WebClient (asynchronous)
private async Task<string> RequestData(string uri)
{
// RESTful API call using WebClient...
}
// Method to request data from the specified URI using WebClient (synchronous)
private string RequestDataSync(string uri)
{
// RESTful API call using WebClient...
}
// Method to make a GET request to the specified API endpoint using RestSharp and deserialize the JSON response
private async Task<dynamic> GetFromApi<dynamic>(String url)
{
// RESTful API call using RestSharp...
}
#endregion
#region User
// Methods for user-related operations...
#endregion
#region Flights
// Method to get current flights information from the Flight Radar 24 API
public List<FlightInfoPartial> GetCurrentFlights()
{
// RESTful API call to retrieve current flights data...
}
// Method to get detailed information about a specific flight from the Flight Radar 24 API
public FlightInfo getSingleFlight(string flightCode)
{
// RESTful API call to retrieve detailed flight data...
}
// Other methods related to flights...
#endregion
#region Weather
// Method to get weather information from the OpenWeather API
public async Task<OpenWeather.Weather> GetWeather(FlightInfo.Airport airport)
{
// RESTful API call to retrieve weather data...
}
#endregion
#region Hebrew Date
// Method to get Hebrew date information from the HebCal API
public async Task<HebCal.Item> GetHebDate(DateTime date)
{
// RESTful API call to retrieve Hebrew date data...
}
#endregion
}
}