Updated Chart Fetch functions in order to create a more generic template
This commit is contained in:
@ -127,18 +127,8 @@ namespace EFB.Controllers
|
||||
|
||||
/*-----Chart Fetching Operations--------*/
|
||||
|
||||
//Prepare data to be send off with request(charts)
|
||||
headerData = new Dictionary<string, string>();
|
||||
headerData.Add("referer", "luke-else.co.uk");
|
||||
|
||||
Dictionary<string, string> formData = new Dictionary<string, string>();
|
||||
|
||||
formData.Add("token", Environment.GetEnvironmentVariable("ChartFoxAPIKey", EnvironmentVariableTarget.User));
|
||||
var body = new FormUrlEncodedContent(formData);
|
||||
|
||||
//make Charts request
|
||||
var requestDepartureCharts = API.Post<ChartResponse>($"https://chartfox.org/api/charts/grouped/{departure}", headerData, body);
|
||||
var requestArrivalCharts = API.Post<ChartResponse>($"https://chartfox.org/api/charts/grouped/{arrival}", headerData, body);
|
||||
var requestDepartureCharts = ChartModel.FetchAsync(departure);
|
||||
var requestArrivalCharts = ChartModel.FetchAsync(arrival);
|
||||
|
||||
/*----------------------------------*/
|
||||
|
||||
@ -170,16 +160,16 @@ namespace EFB.Controllers
|
||||
if (collected)
|
||||
{
|
||||
//Get Response from Charts
|
||||
ResponseModel<ChartResponse> responseDepartureCharts = await requestDepartureCharts;
|
||||
if (responseDepartureCharts.Error == null && responseDepartureCharts.Result.Status == "success")
|
||||
ChartList departureCharts = await requestDepartureCharts;
|
||||
if (departureCharts != null)
|
||||
{
|
||||
user.DepartureCharts = new ChartModel(responseDepartureCharts.Result.Response);
|
||||
user.DepartureCharts = new ChartModel(departureCharts);
|
||||
}
|
||||
|
||||
ResponseModel<ChartResponse> responseArrivalCharts = await requestArrivalCharts;
|
||||
if (responseArrivalCharts.Error == null && responseArrivalCharts.Result.Status == "success")
|
||||
ChartList arrivalCharts = await requestArrivalCharts;
|
||||
if (arrivalCharts != null)
|
||||
{
|
||||
user.ArrivalCharts = new ChartModel(responseArrivalCharts.Result.Response);
|
||||
user.ArrivalCharts = new ChartModel(arrivalCharts);
|
||||
}
|
||||
|
||||
//fill in route
|
||||
|
Reference in New Issue
Block a user