Adapted ChartModel to accept an ICAO Code
This commit is contained in:
parent
0c68d05af1
commit
d8a40e64ef
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using EFB.Models;
|
using EFB.Models;
|
||||||
|
using EFB.Models.JSON;
|
||||||
using EFB.Controllers.Form;
|
using EFB.Controllers.Form;
|
||||||
using EFB.Sessions;
|
using EFB.Sessions;
|
||||||
|
|
||||||
@ -31,9 +32,11 @@ namespace EFB.Controllers
|
|||||||
var charts = await ChartModel.FetchAsync(ICAO);
|
var charts = await ChartModel.FetchAsync(ICAO);
|
||||||
if (charts != null)
|
if (charts != null)
|
||||||
{
|
{
|
||||||
ChartModel chartModel = new ChartModel(charts);
|
ChartModel chartModel = new ChartModel(ICAO, charts);
|
||||||
// return ViewCharts(chartModel);
|
//Save the current chart into user model for later access
|
||||||
HttpContext.Session.SetObject("Charts", chartModel);
|
UserModel user = HttpContext.Session.GetObject<UserModel>("User");
|
||||||
|
user.CurrentCharts = chartModel;
|
||||||
|
HttpContext.Session.SetObject("User", user);
|
||||||
return RedirectToAction("ViewCharts");
|
return RedirectToAction("ViewCharts");
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
@ -43,8 +46,8 @@ namespace EFB.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult ViewCharts(){
|
public IActionResult ViewCharts(Chart chart){
|
||||||
ChartModel charts = HttpContext.Session.GetObject<ChartModel>("Charts");
|
ChartModel charts = HttpContext.Session.GetObject<UserModel>("User").CurrentCharts;
|
||||||
if (charts != null)
|
if (charts != null)
|
||||||
{
|
{
|
||||||
return View("ViewCharts", charts);
|
return View("ViewCharts", charts);
|
||||||
|
@ -163,13 +163,13 @@ namespace EFB.Controllers
|
|||||||
ChartList departureCharts = await requestDepartureCharts;
|
ChartList departureCharts = await requestDepartureCharts;
|
||||||
if (departureCharts != null)
|
if (departureCharts != null)
|
||||||
{
|
{
|
||||||
user.DepartureCharts = new ChartModel(departureCharts);
|
user.DepartureCharts = new ChartModel(departure, departureCharts);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChartList arrivalCharts = await requestArrivalCharts;
|
ChartList arrivalCharts = await requestArrivalCharts;
|
||||||
if (arrivalCharts != null)
|
if (arrivalCharts != null)
|
||||||
{
|
{
|
||||||
user.ArrivalCharts = new ChartModel(arrivalCharts);
|
user.ArrivalCharts = new ChartModel(arrival, arrivalCharts);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fill in route
|
//fill in route
|
||||||
|
@ -18,6 +18,7 @@ namespace EFB.Models
|
|||||||
{
|
{
|
||||||
public class ChartModel
|
public class ChartModel
|
||||||
{
|
{
|
||||||
|
public string ICAO { get; set; }
|
||||||
public Chart[] General { get; set; }
|
public Chart[] General { get; set; }
|
||||||
public Chart[] TextualData { get; set; }
|
public Chart[] TextualData { get; set; }
|
||||||
public Chart[] GroundLayout { get; set; }
|
public Chart[] GroundLayout { get; set; }
|
||||||
@ -31,8 +32,9 @@ namespace EFB.Models
|
|||||||
public ChartModel(){
|
public ChartModel(){
|
||||||
//Empty constructor for JSON Serialisation Purposes
|
//Empty constructor for JSON Serialisation Purposes
|
||||||
}
|
}
|
||||||
public ChartModel(ChartList response)
|
public ChartModel(string ICAO, ChartList response)
|
||||||
{
|
{
|
||||||
|
this.ICAO = ICAO;
|
||||||
General = FillChart(response.General);
|
General = FillChart(response.General);
|
||||||
TextualData = FillChart(response.TextualData);
|
TextualData = FillChart(response.TextualData);
|
||||||
GroundLayout = FillChart(response.GroundLayout);
|
GroundLayout = FillChart(response.GroundLayout);
|
||||||
|
@ -27,7 +27,7 @@ namespace EFB.Models
|
|||||||
//Contains the Departure and Arrival Charts for the user's route
|
//Contains the Departure and Arrival Charts for the user's route
|
||||||
public ChartModel DepartureCharts { get; set; }
|
public ChartModel DepartureCharts { get; set; }
|
||||||
public ChartModel ArrivalCharts { get; set; }
|
public ChartModel ArrivalCharts { get; set; }
|
||||||
public ChartModel CurrentChart { get; set; }
|
public ChartModel CurrentCharts { get; set; }
|
||||||
|
|
||||||
//Contains the most recently stored position of the user in the simulator
|
//Contains the most recently stored position of the user in the simulator
|
||||||
public object SimPosition { get; set; } = null;
|
public object SimPosition { get; set; } = null;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="container jumbotron">
|
<div class="container jumbotron">
|
||||||
<h3>Charts for: @Model.Approach[0].Name</h3>
|
<h3>Charts for: @Model.ICAO</h3>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
Loading…
Reference in New Issue
Block a user