Added and Started on views for Chart Viewer
This commit is contained in:
parent
76878e7745
commit
dd2a367a58
61
Controllers/ChartsController.cs
Normal file
61
Controllers/ChartsController.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EFB.Models;
|
||||
using EFB.Controllers.Form;
|
||||
using EFB.Sessions;
|
||||
|
||||
namespace EFB.Controllers
|
||||
{
|
||||
//[Route("[controller]")]
|
||||
public class ChartsController : Controller
|
||||
{
|
||||
private readonly ILogger<ChartsController> _logger;
|
||||
|
||||
public ChartsController(ILogger<ChartsController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index(string ICAO)
|
||||
{
|
||||
if(ICAO == null)
|
||||
return View();
|
||||
|
||||
if (FormAuthenticator.ValidateICAOCode(ICAO))
|
||||
{
|
||||
var charts = await ChartModel.FetchAsync(ICAO);
|
||||
if (charts != null)
|
||||
{
|
||||
ChartModel chartModel = new ChartModel(charts);
|
||||
// return ViewCharts(chartModel);
|
||||
HttpContext.Session.SetObject("Charts", chartModel);
|
||||
return RedirectToAction("ViewCharts");
|
||||
}
|
||||
}else
|
||||
{
|
||||
TempData["Error"] = "Invalid ICAO";
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ViewCharts(){
|
||||
ChartModel charts = HttpContext.Session.GetObject<ChartModel>("Charts");
|
||||
if (charts != null)
|
||||
{
|
||||
return View("ViewCharts", charts);
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View("Error!");
|
||||
}
|
||||
}
|
||||
}
|
@ -67,12 +67,13 @@ namespace EFB.Models
|
||||
//make Charts request
|
||||
var requestCharts = await API.Post<ChartResponse>($"https://chartfox.org/api/charts/grouped/{ICAO}", headerData, body);
|
||||
Console.WriteLine("End");
|
||||
return requestCharts.Result.Response;
|
||||
}else
|
||||
if (requestCharts.Result.Status == "success")
|
||||
{
|
||||
return null;
|
||||
return requestCharts.Result.Response;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class Pinned
|
||||
|
@ -54,6 +54,12 @@ namespace EFB
|
||||
endpoints.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
// endpoints.MapControllerRoute(
|
||||
// name: "Navdata",
|
||||
// pattern: "{controller=Navdata}/{action=Index}/{identifier?}");
|
||||
// endpoints.MapControllerRoute(
|
||||
// name: "Charts",
|
||||
// pattern: "{controller=Charts}/{action=Index}/{ICAO?}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
37
Views/Charts/Index.cshtml
Normal file
37
Views/Charts/Index.cshtml
Normal file
@ -0,0 +1,37 @@
|
||||
@{
|
||||
ViewData["Title"] = "Welcome";
|
||||
}
|
||||
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="card-body col-md-6">
|
||||
<div class="container jumbotron">
|
||||
<h3>Chart Lookup</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form asp-controller="Charts" asp-action="Index">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary">Search</button>
|
||||
|
||||
@{
|
||||
if (TempData["Error"] != null)
|
||||
{//If an error has been flagged, information will be displayed to the user
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />×
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
93
Views/Charts/ViewCharts.cshtml
Normal file
93
Views/Charts/ViewCharts.cshtml
Normal file
@ -0,0 +1,93 @@
|
||||
@model EFB.Models.ChartModel;
|
||||
@{
|
||||
ViewData["Title"] = "Welcome";
|
||||
}
|
||||
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="card-body col-md-4">
|
||||
<div class="container jumbotron">
|
||||
<h3>Chart Lookup</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form asp-controller="Charts" asp-action="Index">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary">Search</button>
|
||||
|
||||
@{
|
||||
if (TempData["Error"] != null)
|
||||
{//If an error has been flagged, information will be displayed to the user
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />×
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
<div class="container jumbotron">
|
||||
<h3>Charts for: @Model.Approach[0].Name</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form asp-controller="Charts" asp-action="Index">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary">Search</button>
|
||||
|
||||
@{
|
||||
if (TempData["Error"] != null)
|
||||
{//If an error has been flagged, information will be displayed to the user
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />×
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body col-md-8">
|
||||
<div class="container jumbotron">
|
||||
<h3>Chart Lookup</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form asp-controller="Charts" asp-action="Index">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="ICAO Code" name="ICAO" value="@TempData["ICAO"]">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary">Search</button>
|
||||
|
||||
@{
|
||||
if (TempData["Error"] != null)
|
||||
{//If an error has been flagged, information will be displayed to the user
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<strong>Warning!</strong> @TempData["Error"] <button type='button' class='close' data-dismiss='alert' aria-hidden='true' />×
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
<a class="nav-link text-light" asp-area="" asp-controller="Navdata" asp-action="Index">Navdata</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-light" asp-area="" asp-controller="" asp-action="Index">Charts</a>
|
||||
<a class="nav-link text-light" asp-area="" asp-controller="Charts" asp-action="Index">Charts</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-light" asp-area="" asp-controller="" asp-action="Index">FlightSim</a>
|
||||
|
Loading…
Reference in New Issue
Block a user