Altered user model and updated controller to make Chart requests on load
This commit is contained in:
parent
94393e232c
commit
21aff4096f
@ -71,11 +71,25 @@ namespace EFB.Controllers
|
||||
preferredmaxlevel = cruiseAlt / 1000,
|
||||
};
|
||||
StringContent content = new StringContent(JsonConvert.SerializeObject(routeRequest), Encoding.UTF8, "application/json");
|
||||
|
||||
|
||||
//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
|
||||
|
@ -24,6 +24,10 @@ namespace EFB.Models
|
||||
public string Route { get; set; }
|
||||
public TokenModel RouteToken { get; set; } = null;
|
||||
|
||||
//Contains the Departure and Arrival Charts for the user's route
|
||||
public ChartModel DepartureCharts { get; set; }
|
||||
public ChartModel ArrivalCharts { get; set; }
|
||||
|
||||
//Contains the most recently stored position of the user in the simulator
|
||||
public object SimPosition { get; set; } = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user