public void CanValidateCityCoords()
        {
            // Pointer to MakeRouteViewModel
            MakeRouteViewModel makeRoute = new MakeRouteViewModel();

            makeRoute.EndPointLatitude = "35,0394344329834";
            makeRoute.EndPointLongitude = "48,46062862564409";
            makeRoute.StartPointLatitude = "35,03368377685547";
            makeRoute.StartPointLongitude = "48,45146411408362";

            // Create the instance of the ValidateServerHelper and compare the expected result with real
            ValidateServerHelper validateServer = new ValidateServerHelper();
            ValidationResult vr = validateServer.IsValidCoords(makeRoute);
            Assert.IsTrue( vr == ValidationResult.Success );
        }
        public void CanValidateServerData()
        {
            // Pointer to MakeRouteViewModel
            MakeRouteViewModel makeRoute = new MakeRouteViewModel();

            makeRoute.AddressPointA = "пр.Кирова 59";
            makeRoute.AddressPointB = "пр.Пушкина 55";
            makeRoute.EndPointLatitude = "35,0394344329834";
            makeRoute.EndPointLongitude = "48,46062862564409";
            makeRoute.StartPointLatitude = "35,03368377685547";
            makeRoute.StartPointLongitude = "48,45146411408362";

            ValidateServer validateServer = new ValidateServer();
            Assert.IsTrue(validateServer.IsValid( makeRoute ));
        }
        /// <summary>
        /// The overrided Server Validation method.
        /// </summary>
        public ValidationResult IsValidCoords(MakeRouteViewModel makerouteVieModel)
        {
            var jsonObj = makerouteVieModel; // cast the object to type MakeRouteViewModel

            /// Coordinates of the boundary of Dnepropetrovsk
            var polyCoords = new
            {
                SWLong = GeneralSettings.GetSouthWestLongitude,
                SWLat = GeneralSettings.GetSouthWestLatitude,
                NELong = GeneralSettings.GetNorthEastLongitude,
                NELat = GeneralSettings.GetNorthEastLatitude
            };

            double startPointLon;
            double startPointLat;
            double endPointLon;
            double endPointLat;

            // Convert the the Latitudes and Longitudes to type of double
            bool convertFlg = (double.TryParse(jsonObj.StartPointLongitude, out startPointLon)
            & double.TryParse(jsonObj.StartPointLatitude, out startPointLat)
            & double.TryParse(jsonObj.EndPointLongitude, out endPointLon)
            & double.TryParse(jsonObj.EndPointLatitude, out endPointLat));

            /// Verify that the Point A and Point B are in the boundries of Dnepropetrovsk
            if (convertFlg == true
            && startPointLon >= polyCoords.SWLong
            && startPointLon <= polyCoords.NELong
            && startPointLat <= polyCoords.NELat
            && startPointLat >= polyCoords.SWLat
            && endPointLon >= polyCoords.SWLong
            && endPointLon <= polyCoords.NELong
            && endPointLat <= polyCoords.NELat
            && endPointLat >= polyCoords.SWLat)
                return ValidationResult.Success;
            else
            {
                return new ValidationResult(Resources.Resources.ValidationCoords);
            }
        }
        public JsonResult Index(MakeRouteViewModel makeRouteViewModel, ValidateServerHelper validateCoords)
        {
            if (validateCoords.IsValidCoords(makeRouteViewModel) == ValidationResult.Success)
            {
                var startPoint = new MapPoint(
                    Convert.ToDouble(makeRouteViewModel.StartPointLatitude),
                    Convert.ToDouble(makeRouteViewModel.StartPointLongitude));
                var endPoint = new MapPoint(
                    Convert.ToDouble(makeRouteViewModel.EndPointLatitude),
                    Convert.ToDouble(makeRouteViewModel.EndPointLongitude));
                var args = new List<Transport> { Transport.All };
                var invalidDirections =
                    this.directionProvider.All().ToList().Select(direction => direction.Direction).ToList();
                var invalidWords =
                    this.invalidCharacterProvider.All().ToList().Select(invalidWord => invalidWord.InvalidWord).ToList();
                var validWords =
                    this.invalidCharacterProvider.All().ToList().Select(validWord => validWord.ValidWord).ToList();
                var allRoutes = this.routeSeach.GetAppropriateRoutes(
                    this.routeProvider.All(),
                    invalidDirections,
                    validWords,
                    invalidWords,
                    endPoint.ToSqlGeography(),
                    startPoint.ToSqlGeography(),
                    args);
                var routes = ModelConverter.Convert(allRoutes);

                return this.Json(routes);
            }
            else
            {
                return Json(makeRouteViewModel);
            }
        }