Exemplo n.º 1
0
 public bool UpdateHitchBotLocation(int HitchBotID, double Latitude, double Longitude, double Altitude, float Accuracy, float Velocity, string TakenTime)
 {
     DateTime StartTimeReal = DateTime.ParseExact(TakenTime, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
     using (var db = new Models.Database())
     {
         var hitchBOT = db.hitchBOTs.Include(l => l.Locations).First(h => h.ID == HitchBotID);
         var location = new Location();
         location.Latitude = Latitude;
         location.Longitude = Longitude;
         location.Altitude = Altitude;
         location.Accuracy = Accuracy;
         location.Velocity = Velocity;
         location.TakenTime = StartTimeReal;
         location.TimeAdded = DateTime.UtcNow;
         location.HitchBOT = hitchBOT;
         db.Locations.Add(location);
         db.SaveChanges();
         hitchBOT.Locations.Add(location);
         db.SaveChanges();
     }
     return true;
 }
Exemplo n.º 2
0
        public bool UpdateHitchBotLocationMin(string HitchBotID, string Latitude, string Longitude, string TakenTime)
        {
            DateTime StartTimeReal = DateTime.ParseExact(TakenTime, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
            int newLocationID;
            int hitchBotID;
            using (var db = new Models.Database())
            {
                hitchBotID = int.Parse(HitchBotID);
                double LatDouble = double.Parse(Latitude);
                double LongDouble = double.Parse(Longitude);
                var hitchBOT = db.hitchBOTs.Include(h => h.Locations).First(h => h.ID == hitchBotID);
                var location = new Location()
                {
                    Latitude = LatDouble,
                    Longitude = LongDouble,
                    TakenTime = StartTimeReal,
                    TimeAdded = DateTime.UtcNow,
                    HitchBOT = hitchBOT
                };

                db.Locations.Add(location);
                db.SaveChanges();
                //hitchBOT.Locations.Add(location);
                //db.SaveChanges();

                newLocationID = location.ID;
            }

            //Helpers.LocationHelper.CheckForTargetLocation(hitchBotID, newLocationID);
            return true;
        }