From c41818848129d0114be9f143ed2a595943f7df4a Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 18 Feb 2022 22:43:01 +0000 Subject: [PATCH] Completed app page + added metar class --- Controllers/AppController.cs | 19 +++++++------- Controllers/RouteController.cs | 2 +- EFB.csproj | 1 + Metar/Metar.cs | 32 +++++++++++++++++++++++ Views/App/Index.cshtml | 48 ++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 Metar/Metar.cs create mode 100644 Views/App/Index.cshtml diff --git a/Controllers/AppController.cs b/Controllers/AppController.cs index a0056ea..e8354c2 100644 --- a/Controllers/AppController.cs +++ b/Controllers/AppController.cs @@ -23,18 +23,17 @@ namespace EFB.Controllers public IActionResult Index() { //Check to see what point on the application the user is at and where they should be sent - UserModel User = HttpContext.Session.GetObject("User"); - if (User != null) + UserModel user = HttpContext.Session.GetObject("User"); + if (user == null) { - if (User.Route == null) - { - return RedirectToAction("Index", "Route"); - }else{ - return RedirectToAction("Index", "App"); - } - }else{ - return RedirectToAction("Index", "Home"); + return RedirectToAction("Index", "Home"); } + if (user.Route == null) + { + return RedirectToAction("Index", "Route"); + } + + return View(user); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/Controllers/RouteController.cs b/Controllers/RouteController.cs index e948e20..51bf22d 100644 --- a/Controllers/RouteController.cs +++ b/Controllers/RouteController.cs @@ -185,7 +185,7 @@ namespace EFB.Controllers user.Cruise = cruise; HttpContext.Session.SetObject("User", user); - return RedirectToAction("Index", "Route"); + return RedirectToAction("Index", "App"); } TempData["Error"] = $"Unable to get route after {pollCount} Attempts!"; diff --git a/EFB.csproj b/EFB.csproj index 834e592..66ae2ff 100644 --- a/EFB.csproj +++ b/EFB.csproj @@ -7,5 +7,6 @@ + \ No newline at end of file diff --git a/Metar/Metar.cs b/Metar/Metar.cs new file mode 100644 index 0000000..80bcc5f --- /dev/null +++ b/Metar/Metar.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using libmetar.Services; + +namespace EFB.Metar +{ + public static class Metar + { + private static MetarService metarService { get; set; } = new MetarService(); + private static TafService tafService { get; set; } = new TafService(); + + + public static async Task GetMETAR(string ICAO){ + return (await metarService.GetRawAsync(ICAO)).Raw; + } + + public static async Task> GetTAF(string ICAO){ + var downloadedTAF = (await tafService.GetRawAsync(ICAO)).RawSplit; + List TAF = new List(); + + foreach (var line in downloadedTAF) + { + TAF.Add(line); + } + return TAF; + } + + + } +} \ No newline at end of file diff --git a/Views/App/Index.cshtml b/Views/App/Index.cshtml new file mode 100644 index 0000000..72c9b13 --- /dev/null +++ b/Views/App/Index.cshtml @@ -0,0 +1,48 @@ +@using EFB.Metar; +@model EFB.Models.UserModel; +@{ + ViewData["Title"] = "Welcome"; +} + +
+
+
+

Current Session - @Model.EMail

+ +
+
+ + +
+
+

Departure

+ @Model.Departure + +
+ + @await Metar.GetMETAR(Model.Departure) + +

Cruise

+ @Model.Cruise ft +
+
+

Arrival

+ @Model.Arrival + +
+ + @await Metar.GetMETAR(Model.Arrival) +
+
+ +
+ +

Route

+ @Model.Route + +
+
+
+ + +