Beispiel #1
0
        private void MakeSomePoints(double latCentre, double lonCentre, double distanceRand, whatshotEntities1 db, int number)
        {
            var r = new Random();
            double latitude;
            double longitude;
            for (var i = 0; i < number; i++)
            {
                var angle = r.NextDouble() * Math.PI * 2;
                var distance = r.NextDouble() * distanceRand;
                latitude = Math.Cos(angle) * distance + latCentre;
                longitude = Math.Sin(angle) * distance + lonCentre;

                var newvote = new Location()
                {
                    Lat = latitude.ToString(),
                    Long = longitude.ToString(),
                    TimeAdded = DateTime.Now,
                    User_Id = -1,//userId

                };
                db.Locations.Add(newvote);
            }
        }
Beispiel #2
0
        public string PostDestination(string token, string lat, string @long)
        {
            // check if valid token & get user id
            //int userId;
            //if (!_tokenHelper.IsTokenValid(token, out userId)) return "Invalid token";

            double latitude, longitude;

            if (!LocationHelper.IsLat(lat, out latitude) || !(LocationHelper.IsLong(@long, out longitude))) return "Invalid lat/long";

            using (var db = new whatshotEntities1())
            {
                var newvote = new Location()
                {
                    Lat = latitude.ToString(),
                    Long = longitude.ToString(),
                    TimeAdded = DateTime.Now,
                    User_Id = -1//userId
                };

                db.Locations.Add(newvote);
                db.SaveChanges();
            }

            return "blah";
        }