From 8be3b0fa0228a073f7e2f00c0333419e04cdd613 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 18 Feb 2022 17:18:00 +0000 Subject: [PATCH] Added SimPositionModel from flight tracker + setup mongo files --- Controllers/FlightsimController.cs | 32 ++++++++++++++++++ EFB.csproj | 2 ++ Models/SimPositionModel.cs | 53 ++++++++++++++++++++++++++++++ Mongo/Mongo.cs | 15 +++++++++ 4 files changed, 102 insertions(+) create mode 100644 Controllers/FlightsimController.cs create mode 100644 Models/SimPositionModel.cs create mode 100644 Mongo/Mongo.cs diff --git a/Controllers/FlightsimController.cs b/Controllers/FlightsimController.cs new file mode 100644 index 0000000..0e7a17f --- /dev/null +++ b/Controllers/FlightsimController.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace EFB.Controllers +{ + //[Route("[controller]")] + public class FlightsimController : Controller + { + private readonly ILogger _logger; + + public FlightsimController(ILogger logger) + { + _logger = logger; + } + + public IActionResult Index() + { + return View(); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View("Error!"); + } + } +} \ No newline at end of file diff --git a/EFB.csproj b/EFB.csproj index aa74eb8..834e592 100644 --- a/EFB.csproj +++ b/EFB.csproj @@ -5,5 +5,7 @@ + + \ No newline at end of file diff --git a/Models/SimPositionModel.cs b/Models/SimPositionModel.cs new file mode 100644 index 0000000..85e529d --- /dev/null +++ b/Models/SimPositionModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Bson; +using MongoDB.Driver; + +namespace EFB.Models +{ + public class SimPositionModel + { + [BsonId] + public ObjectId Id { get; set; } + public string EMail { get; set; } = ""; + public DateTime LatestPacketUpdate { get; set; } + public SimPosition LatestPosition { get; set; } = null; + + public SimPositionModel(string email, SimPosition position){ + EMail = email; + LatestPacketUpdate = DateTime.Now; + LatestPosition = position; + } + + } + + + public class SimPosition + { + public float Latitude { get; set; } + public float Longitude { get; set; } + public int Altitude { get; set; } + + public SimPosition(float latitude, float longitude, int altitude){ + Latitude = latitude; + Longitude = longitude; + Altitude = altitude; + } + + //**Packet Processing not required**// + + // public SimPosition(Packet[] data){ + // if (data[0].Data != null) + // { + // //Use Linq to search through the packets for a given id and use that data + // Latitude = (data.Where(x => x.Id == 22).Select(x => x.Data[0]).ToArray())[0]; + // Longitude = (data.Where(x => x.Id == 23).Select(x => x.Data[0]).ToArray())[0]; + // Altitude = Convert.ToInt32((data.Where(x => x.Id == 24).Select(x => x.Data[0]).ToArray())[0]); + + // } + // } + } +} \ No newline at end of file diff --git a/Mongo/Mongo.cs b/Mongo/Mongo.cs new file mode 100644 index 0000000..22604ad --- /dev/null +++ b/Mongo/Mongo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDB.Bson; +using EFB.Models; + +namespace EFB.Mongo +{ + public class Mongo + { + + } +} \ No newline at end of file