diff --git a/Controllers/ChartsController.cs b/Controllers/ChartsController.cs index c9ea44a..7ac6db4 100644 --- a/Controllers/ChartsController.cs +++ b/Controllers/ChartsController.cs @@ -52,13 +52,19 @@ namespace EFB.Controllers return View(); } - public IActionResult ViewCharts(Chart chart){ - ChartModel charts = HttpContext.Session.GetObject("User").CurrentCharts; - if (charts != null) + public IActionResult ViewCharts(string chart){ + UserModel user = HttpContext.Session.GetObject("User"); + if (user != null) { - return View("ViewCharts", charts); + ViewChartModel charts = new ViewChartModel(user.CurrentCharts, chart); + + if (charts != null) + { + return View("ViewCharts", charts); + } + return RedirectToAction("Index"); } - return RedirectToAction("Index"); + return RedirectToAction("Index", "Home"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/Models/ViewChartModel.cs b/Models/ViewChartModel.cs new file mode 100644 index 0000000..900e9c7 --- /dev/null +++ b/Models/ViewChartModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Razor; +using Newtonsoft.Json; +using EFB.Models.JSON; +using Microsoft.AspNetCore; +using EFB.Sessions; + +namespace EFB.Models +{ + public class ViewChartModel + { + public ChartModel Charts { get; set; } + public Chart Selected { get; set; } + + public ViewChartModel(ChartModel current, string selected){ + Charts = current; + if (selected != null) + { + Selected = JsonConvert.DeserializeObject(selected); + } + } + } +} \ No newline at end of file diff --git a/Views/Charts/ViewCharts.cshtml b/Views/Charts/ViewCharts.cshtml index dd355ab..068dc32 100644 --- a/Views/Charts/ViewCharts.cshtml +++ b/Views/Charts/ViewCharts.cshtml @@ -1,4 +1,5 @@ -@model EFB.Models.ChartModel; +@using Newtonsoft.Json; +@model EFB.Models.ViewChartModel; @{ ViewData["Title"] = "Welcome"; } @@ -27,53 +28,75 @@ } -

Charts for: @Model.ICAO

+ @{ - +
+
+
+ + +
+
+ } -
-
-

Chart Lookup

+
+
+ @{ + if (Model.Selected != null) + { +

@Model.Selected.Name

-
-
+
+
+ + -
-
- -
- - - @{ - if (TempData["Error"] != null) - {//If an error has been flagged, information will be displayed to the user - -
-
- -
- Warning! @TempData["Error"]
- } } -
+ }
-
- - - +
\ No newline at end of file