Updates to App and route Controller
This commit is contained in:
parent
5845229628
commit
08c2e9c07b
46
Controllers/AppController.cs
Normal file
46
Controllers/AppController.cs
Normal file
@ -0,0 +1,46 @@
|
||||
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 Microsoft.AspNetCore.Http;
|
||||
using EFB.Sessions;
|
||||
|
||||
namespace EFB.Controllers
|
||||
{
|
||||
public class AppController : Controller
|
||||
{
|
||||
private readonly ILogger<AppController> _logger;
|
||||
|
||||
public AppController(ILogger<AppController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
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<UserModel>("User");
|
||||
if (User != null)
|
||||
{
|
||||
if (User.Route == null)
|
||||
{
|
||||
return RedirectToAction("Index", "Route");
|
||||
}else{
|
||||
return RedirectToAction("Index", "App");
|
||||
}
|
||||
}else{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View("Error!");
|
||||
}
|
||||
}
|
||||
}
|
41
Controllers/RouteController.cs
Normal file
41
Controllers/RouteController.cs
Normal file
@ -0,0 +1,41 @@
|
||||
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 Microsoft.AspNetCore.Http;
|
||||
using EFB.Models;
|
||||
using EFB.Sessions;
|
||||
|
||||
namespace EFB.Controllers
|
||||
{
|
||||
public class RouteController : Controller
|
||||
{
|
||||
private readonly ILogger<RouteController> _logger;
|
||||
|
||||
public RouteController(ILogger<RouteController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
//Check the user has a valid login
|
||||
UserModel User = HttpContext.Session.GetObject<UserModel>("User");
|
||||
if (User == null || User.Route != null || User.Token.IsExpired())
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View("Error!");
|
||||
}
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ namespace EFB.Controllers
|
||||
|
||||
//Using Session Extensions (Store the user session)
|
||||
HttpContext.Session.SetObject("User", user);
|
||||
return RedirectToAction("App", "Home");
|
||||
return RedirectToAction("Index", "App");
|
||||
}else{
|
||||
TempData["Error"] = login.error_description;
|
||||
TempData["email"] = email;
|
||||
|
46
Views/Route/Index.cshtml
Normal file
46
Views/Route/Index.cshtml
Normal file
@ -0,0 +1,46 @@
|
||||
@{
|
||||
ViewData["Title"] = "Route Info";
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="card-body col-md-6">
|
||||
<div class="container jumbotron">
|
||||
<h3>Route Info</h3>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form asp-controller="Route" asp-action="New">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Departure" name="Departure" value="@TempData["Departure"]">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Arrival" name="Arrival" value="@TempData["Arrival"]">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Cruise" name="Cruise" value="@TempData["Cruise"]">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary">Get Route</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 mh-100 bg-warning col-md-6">
|
||||
<img src="/images/RouteImage.png" width="100%" height="100%" style="object-fit: cover;">
|
||||
</div>
|
||||
|
||||
</div>
|
BIN
wwwroot/images/RouteImage.png
Normal file
BIN
wwwroot/images/RouteImage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Loading…
Reference in New Issue
Block a user