Added MongoDB Methods and introduced flight sim controller

This commit is contained in:
2022-02-18 18:49:56 +00:00
parent eda71069a4
commit 10af903706
5 changed files with 51 additions and 5 deletions

View File

@ -4,7 +4,10 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EFB.Sessions;
using Microsoft.Extensions.Logging;
using EFB.Models;
using EFB.MongoData;
namespace EFB.Controllers
{
@ -18,8 +21,17 @@ namespace EFB.Controllers
_logger = logger;
}
public IActionResult Index()
public async Task<IActionResult> Index()
{
//Retrieve and Check current user status
UserModel user = HttpContext.Session.GetObject<UserModel>("User");
if(user == null) return RedirectToAction("Index", "Home");
//Retrieve the user's latest sim position and construct it into FlightsimModel
SimPositionModel latestPosition = await Mongo.GetLatestData(user.EMail);
// RouteModel route = RouteModel.StringToRoute();
return View();
}

View File

@ -175,6 +175,8 @@ namespace EFB.Controllers
//fill in route
string finalRoute = RouteModel.ParseRoute(routeString);
user.Route = finalRoute;
user.Departure = departure;
user.Arrival = arrival;
HttpContext.Session.SetObject("User", user);
return RedirectToAction("Index", "Route");