EFB/Controllers/AppController.cs

45 lines
1.2 KiB
C#

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)
{
return RedirectToAction("Index", "Home");
}
if (user.Route == null)
{
return RedirectToAction("Index", "Route");
}
return View(user);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View("Error!");
}
}
}