Add Update route controller to fetch charts and adapt model to allow for response parsing
This commit is contained in:
@ -75,21 +75,7 @@ namespace EFB.Controllers
|
||||
//Make initial Route Request
|
||||
var requestRoute = API.Post<string>("https://api.autorouter.aero/v1.0/router", headerData, content);
|
||||
|
||||
//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", "");
|
||||
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);
|
||||
|
||||
ResponseModel<string> responseRoute = await requestRoute;
|
||||
ResponseModel<ChartResponse> responseDepartureCharts = await requestDepartureCharts;
|
||||
ResponseModel<ChartResponse> responseArrivalCharts = await requestArrivalCharts;
|
||||
|
||||
if (responseRoute.Error == null)
|
||||
{//Update User session and add route ID
|
||||
@ -137,8 +123,25 @@ namespace EFB.Controllers
|
||||
string routeString = "";
|
||||
|
||||
APIInterface API = new APIInterface();
|
||||
|
||||
Dictionary<string, string> headerData = new Dictionary<string, string>();
|
||||
|
||||
/*-----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", "");
|
||||
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);
|
||||
|
||||
/*----------------------------------*/
|
||||
|
||||
//Run route Polling
|
||||
headerData.Add("Authorization", $"Bearer {user.UserToken.TokenValue}");
|
||||
|
||||
while (collected == false && pollCount < 15)
|
||||
@ -165,6 +168,13 @@ namespace EFB.Controllers
|
||||
|
||||
if (collected)
|
||||
{
|
||||
//Get Response from Charts
|
||||
ResponseModel<ChartResponse> responseDepartureCharts = await requestDepartureCharts;
|
||||
user.DepartureCharts = new ChartModel(responseDepartureCharts.Result.Response);
|
||||
|
||||
ResponseModel<ChartResponse> responseArrivalCharts = await requestArrivalCharts;
|
||||
user.ArrivalCharts = new ChartModel(responseArrivalCharts.Result.Response);
|
||||
|
||||
//fill in route
|
||||
string finalRoute = RouteModel.ParseRoute(routeString);
|
||||
user.Route = finalRoute;
|
||||
|
Reference in New Issue
Block a user