Added Navdata View (Needs Tweaking)

This commit is contained in:
2022-02-01 20:25:31 +00:00
parent ef4d44d7d2
commit 58eef9ea67
3 changed files with 102 additions and 7 deletions

View File

@ -5,6 +5,8 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using EFB.Models;
using EFB.Sessions;
namespace EFB.Controllers
{
@ -18,9 +20,30 @@ namespace EFB.Controllers
_logger = logger;
}
public IActionResult Index()
public async Task<IActionResult> Index(string identifier)
{
return View();
if (identifier == null)
{//In the event we are just going to the base page1
return View();
}
NavdataModel[] data = null;
if (HttpContext.Session.GetObject<NavdataModel[]>("Navdata") == null)
{//If the navdata needs re-caching
data = await NavdataModel.Populate();
HttpContext.Session.SetObject("Navdata", NavdataModel.MergeSort(ref data, 0, data.Length-1));
}
//get the data out of tempdata and cast it into an array
data = HttpContext.Session.GetObject<NavdataModel[]>("Navdata");
NavdataModel navaid = NavdataModel.BinarySearch(ref data, 0, data.Length-1, identifier);
if (navaid == null)
{
TempData["Error"] = $"Sorry, no Navaid found with the name {identifier}";
}
return View(navaid);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]