From e1347517456663345d7de9494a65c0971a057e16 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Mon, 27 Dec 2021 21:15:55 +0000 Subject: [PATCH] Updated UserModel and started on making the polling http calls to the server. Started with the Polling command: What I'm thinking is that I should have the command consecutively make calls every 5 seconds, not sure how it will work without hanging the thread, will figure out tomorrow :) --- Controllers/RouteController.cs | 21 +++++++++++++++++++++ Models/UserModel.cs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Controllers/RouteController.cs b/Controllers/RouteController.cs index ba0281a..78da5c6 100644 --- a/Controllers/RouteController.cs +++ b/Controllers/RouteController.cs @@ -100,5 +100,26 @@ namespace EFB.Controllers } return RedirectToAction("Index", "Home"); } + + + public async Task Poll(){ + if (HttpContext.Session.GetString("User") != null) + {//If the user is currently logged in + UserModel User = HttpContext.Session.GetObject("User"); + + if (User.Route != null) + {//If the user has a route object (e.g, they have been to the route page) + + //Make calls to the server to fetch route + return RedirectToAction("Index", "Route"); + + }else{ + return RedirectToAction("Index", "Route"); + } + + }else{ + return RedirectToAction("Index", "Route"); + } + } } } \ No newline at end of file diff --git a/Models/UserModel.cs b/Models/UserModel.cs index e4e2dce..500b82e 100644 --- a/Models/UserModel.cs +++ b/Models/UserModel.cs @@ -21,7 +21,7 @@ namespace EFB.Models public TokenModel Token { get; set; } = null; //Contains the most recent route generated by the user through the App - public object Route { get; set; } = null; + public RouteModel Route { get; set; } = null; //Contains the most recently stored position of the user in the simulator public object SimPosition { get; set; } = null;