private static void RandomLocationCity(WorkoutsOld oWorkoutsOld, Random rnd)
        {
            string[] citiesList = new string[] { "Madrid", "Madrid", "Madrid", "Madrid", "Madrid", "Barcelona", "Barcelona", "Barcelona", "Valencia", "Valencia", "Bilbao", "Coruña", "Sevilla", "Santader", "Badajoz", "León", "Murcia", "Albacete", "Toledo", "Zaragoza" };


            int    r    = rnd.Next(citiesList.Length);
            string city = (string)citiesList[r];

            string zone = string.Empty;

            if (city == "Madrid")
            {
                zone = RandomZoneMadrid(rnd);
            }
            else
            {
                if (city == "Barcelona")
                {
                    zone = RandomZoneBarcelona(rnd);
                }
            }

            oWorkoutsOld.Zone    = zone.ToUpper();
            oWorkoutsOld.City    = city;
            oWorkoutsOld.Region  = city;
            oWorkoutsOld.Country = "Spain";
        }
        private static void RandomCircular(WorkoutsOld oWorkoutsOld, Random rnd)
        {
            bool result = rnd.Next(2) == 0;

            oWorkoutsOld.Circular = result;

            if (!oWorkoutsOld.Circular)
            {
                //oWorkoutsOld.EndLocation = RandomLocationEnd(oWorkoutsOld);
            }
        }
        private static void RandomLocation(WorkoutsOld oWorkoutsOld, Random rnd)
        {
            string[] citiesList = new string[] { "Madrid", "Madrid", "Madrid", "Madrid", "Madrid", "Barcelona", "Barcelona", "Barcelona", "Valencia", "Valencia", "Bilbao", "Coruña", "Sevilla", "Santader", "Badajoz", "León", "Murcia", "Albacete", "Toledo", "Zaragoza" };

            Dictionary <string, DbGeography> DbGeographyList = new Dictionary <string, DbGeography>();

            DbGeographyList.Add("Madrid", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Barcelona", DbGeography.FromText("POINT(2.175297 41.395208)"));
            DbGeographyList.Add("Valencia", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Bilbao", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Coruña", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Sevilla", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Santader", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Badajoz", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("León", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Murcia", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Albacete", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Toledo", DbGeography.FromText("POINT(-3.703479 40.417241)"));
            DbGeographyList.Add("Zaragoza", DbGeography.FromText("POINT(-3.703479 40.417241)"));

            int    r    = rnd.Next(citiesList.Length);
            string city = (string)citiesList[r];


            DbGeography oDbGeography = (DbGeography)DbGeographyList[city];

            double EarthRadius = 6371000;

            int    MaxMeters = 10000;
            Random rndMeters = new Random();
            int    rMeters   = rndMeters.Next(MaxMeters);

            int    MaxBearing = 360;
            Random rndBearing = new Random();
            double rBearing   = rndMeters.NextDouble() * MaxBearing;

            var omega1  = oDbGeography.Latitude.Value;
            var lampda1 = oDbGeography.Longitude.Value;

            double sigma = (double)rMeters / EarthRadius;


            var omega2 = Math.Asin(Math.Sin(omega1) * Math.Cos(sigma) +
                                   Math.Cos(omega1) * Math.Sin(sigma) * Math.Cos(rBearing));
            var lampda2 = lampda1 + Math.Atan2(Math.Sin(rBearing) * Math.Sin(sigma) * Math.Cos(omega1),
                                               Math.Cos(sigma) - Math.Sin(omega1) * Math.Sin(omega2));

            oWorkoutsOld.StartLocation = DbGeography.FromText("POINT(" + lampda2 + " " + omega2 + ")");

            oWorkoutsOld.City    = city;
            oWorkoutsOld.Region  = city;
            oWorkoutsOld.Country = "Spain";
        }
        public static List <WorkoutsOld> PopulateData()
        {
            Random             rnd             = new Random();
            List <WorkoutsOld> WorkoutsOldList = new List <WorkoutsOld>();

            for (int i = 0; i < DataNumber; i++)
            {
                WorkoutsOld oWorkoutsOld = new WorkoutsOld();
                oWorkoutsOld.StartDateTime = RandomDay(rnd);
                RandomLocationCity(oWorkoutsOld, rnd);
                //RandomLocation(oWorkoutsOld, rnd);
                oWorkoutsOld.AVGPace  = RandomTime(rnd);
                oWorkoutsOld.Distance = RandomDistance(rnd);
                RandomCircular(oWorkoutsOld, rnd);
                oWorkoutsOld.MaxNumberPeople = RandomMaxNumberPeople(rnd);
                oWorkoutsOld.ElevationGain   = RandomElevation(rnd);
                oWorkoutsOld.UsersId         = 1;
                WorkoutsOldList.Add(oWorkoutsOld);
            }


            return(WorkoutsOldList);
        }
 private static DbGeography RandomLocationEnd(WorkoutsOld oWorkoutsOld)
 {
     throw new NotImplementedException();
 }