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