Completed app page + added metar class
This commit is contained in:
parent
ec5ca51602
commit
c418188481
@ -23,18 +23,17 @@ namespace EFB.Controllers
|
|||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
//Check to see what point on the application the user is at and where they should be sent
|
//Check to see what point on the application the user is at and where they should be sent
|
||||||
UserModel User = HttpContext.Session.GetObject<UserModel>("User");
|
UserModel user = HttpContext.Session.GetObject<UserModel>("User");
|
||||||
if (User != null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
if (User.Route == null)
|
return RedirectToAction("Index", "Home");
|
||||||
{
|
|
||||||
return RedirectToAction("Index", "Route");
|
|
||||||
}else{
|
|
||||||
return RedirectToAction("Index", "App");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return RedirectToAction("Index", "Home");
|
|
||||||
}
|
}
|
||||||
|
if (user.Route == null)
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index", "Route");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
@ -185,7 +185,7 @@ namespace EFB.Controllers
|
|||||||
user.Cruise = cruise;
|
user.Cruise = cruise;
|
||||||
HttpContext.Session.SetObject("User", user);
|
HttpContext.Session.SetObject("User", user);
|
||||||
|
|
||||||
return RedirectToAction("Index", "Route");
|
return RedirectToAction("Index", "App");
|
||||||
}
|
}
|
||||||
|
|
||||||
TempData["Error"] = $"Unable to get route after {pollCount} Attempts!";
|
TempData["Error"] = $"Unable to get route after {pollCount} Attempts!";
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
<PackageReference Include="MySql.Data" Version="*"/>
|
<PackageReference Include="MySql.Data" Version="*"/>
|
||||||
<PackageReference Include="MongoDB.Driver" Version="*"/>
|
<PackageReference Include="MongoDB.Driver" Version="*"/>
|
||||||
<PackageReference Include="MongoDB.Bson" Version="*"/>
|
<PackageReference Include="MongoDB.Bson" Version="*"/>
|
||||||
|
<PackageReference Include="libmetar" Version="*"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
32
Metar/Metar.cs
Normal file
32
Metar/Metar.cs
Normal file
@ -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<string> GetMETAR(string ICAO){
|
||||||
|
return (await metarService.GetRawAsync(ICAO)).Raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<List<string>> GetTAF(string ICAO){
|
||||||
|
var downloadedTAF = (await tafService.GetRawAsync(ICAO)).RawSplit;
|
||||||
|
List<string> TAF = new List<string>();
|
||||||
|
|
||||||
|
foreach (var line in downloadedTAF)
|
||||||
|
{
|
||||||
|
TAF.Add(line);
|
||||||
|
}
|
||||||
|
return TAF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
48
Views/App/Index.cshtml
Normal file
48
Views/App/Index.cshtml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@using EFB.Metar;
|
||||||
|
@model EFB.Models.UserModel;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Welcome";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="row d-flex">
|
||||||
|
<div class="card-body col-md-12 bg-primary">
|
||||||
|
<div class="container jumbotron">
|
||||||
|
<h3>Current Session - @Model.EMail</h3>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row d-flex">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h4>Departure</h4>
|
||||||
|
@Model.Departure
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
@await Metar.GetMETAR(Model.Departure)
|
||||||
|
|
||||||
|
<h4>Cruise</h4>
|
||||||
|
@Model.Cruise ft
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h4>Arrival</h4>
|
||||||
|
@Model.Arrival
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
@await Metar.GetMETAR(Model.Arrival)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<h4>Route</h4>
|
||||||
|
@Model.Route
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user