public ActionResult LocationIndoorNew(string countryUrlPart, string areaNameUrlPart, LocationIndoorNewViewModel m) { PerformLocationAddValidation(areaNameUrlPart, m.Latitude, m.Longitude, m.Name, AppLookups.Country(countryUrlPart), true); if (ModelState.IsValid) { var location = geoSvc.CreateLocationIndoor(new LocationIndoor() { Address = m.Address, MapAddress = m.Address, CountryID = m.CountryID, Latitude = m.Latitude, Longitude = m.Longitude, Name = m.Name, Website = m.Website, TypeID = m.TypeID }); return(Redirect(location.SlugUrl)); } else { var country = AppLookups.Country(countryUrlPart); ViewBag.Country = country; var area = new GeoService().GetArea(country.ID, areaNameUrlPart); ViewBag.Area = area; ViewBag.ExistingLocations = new GeoService().GetLocationsOfArea(area.ID).Where( a => a.Type == CfType.CommercialIndoorClimbing || a.Type == CfType.PrivateIndoorClimbing).ToList(); return(View(m)); } }
public JsonResult SearchAreaForNewArea(string parentAreaID, string countryUrlPart, string locality) { var country = AppLookups.Country(countryUrlPart); Guid parentID; Area parentArea = default(Area); if (Guid.TryParse(parentAreaID, out parentID)) { parentArea = geoSvc.GetAreaByID(parentID); } List <GeocodeResult> results = new List <GeocodeResult>(); if (parentArea == default(Area)) { results = new GeocodeService().Geocode(country, locality); } else { //-- we need to blur the geography otherwise places that are coast to the coast fail... SqlGeography blurredGeo = parentArea.Geo.STBuffer(1500); //-- 1.5Km buffer zone results = new GeocodeService().Geocode(country, locality, blurredGeo); } if (results.Count == 0) { return(Json(new { Success = false })); } else { return(Json(new { Success = true, Results = results })); } }
public static MvcHtmlString FlagImage(this HtmlHelper helper, IHasCountry obj) { if (obj.CountryID == 0 || obj.CountryID == 117) { return(new MvcHtmlString(string.Format(@"<img src=""{0}/flags/nn.png"" alt=""Unknown Country"" />", Stgs.StaticRt))); } return(FlagImage(helper, AppLookups.Country(obj.CountryID))); }
public Message GetCountry(string id) { //-- TODO: check country and pass back friendly error if not found page var countryWithOutGeo = AppLookups.Country(id); var country = geoSvc.GetCountryByID(countryWithOutGeo.ID); var mapItemCollection = mapSvc.GetCountryMapItems(country); return(ReturnMapItemCollectionAsJson(mapItemCollection)); }
public JsonResult SearchAreaForNewLocationIndoor(string countryUrlPart, string locality) { //-- Step 1) Make a GeoCoding call to Bing var country = AppLookups.Country(countryUrlPart); List <GeocodeResult> results = new GeocodeService().Geocode(country, locality); if (results.Count == 0) { return(Json(new { Success = false })); } return(Json(new { Success = true, Results = results })); }
public static MvcHtmlString PlaceLinkWithFlag(this HtmlHelper helper, Guid placeID) { var place = AppLookups.GetCacheIndexEntry(placeID); if (place == null) { return(new MvcHtmlString("")); } var country = AppLookups.Country(place.CountryID); return(new MvcHtmlString( string.Format(@"<img src=""{0}/flags/{1}.png"" /> <a href=""{2}"">{3}</a>", Stgs.StaticRt, country.Flag, place.SlugUrl, place.Name))); }
public ActionResult Climb(string nameUrlPart, Guid id) { var c = geoSvc.GetClimbByID(id); if (c == default(Climb)) { return(PlaceNotFound()); } ViewBag.Country = AppLookups.Country(c.CountryID); var pageHeading = string.Format("of <a href='{0}'>{1}</a>", c.SlugUrl, c.Name); var model = new ViewerViewModel(c.ID, "climb", c.Name, c.SlugUrl, mediaSvc.GetObjectsMedia(c.ID), pageHeading); return(View("Viewer", model)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { Country country = null; string countryUrlPart = null; bool countryUrlPartInvalid = false; //-- First check route data if (filterContext.RouteData.Values["countryUrlPart"] != null) { countryUrlPart = filterContext.RouteData.Values["countryUrlPart"].ToString(); } //-- If route data fails, double check http query string and form parameters if (string.IsNullOrWhiteSpace(countryUrlPart)) { if (filterContext.RequestContext.HttpContext.Request["countryUrlPart"] != null) { countryUrlPart = filterContext.RequestContext.HttpContext.Request["countryUrlPart"].ToString(); } } if (string.IsNullOrWhiteSpace(countryUrlPart)) { countryUrlPartInvalid = true; } else { country = AppLookups.Country(countryUrlPart); if (country == default(Country)) { countryUrlPartInvalid = true; } } if (countryUrlPartInvalid) { filterContext.Result = new RedirectToRouteResult("PlaceNotFound", null); } else { filterContext.Controller.ViewBag.Country = country; } base.OnActionExecuting(filterContext); }
public ActionResult ClimbDetail(Guid id, string nameUrlPart) { var cacheClimb = AppLookups.GetCacheIndexEntry(id); ViewBag.Country = AppLookups.Country(cacheClimb.CountryID); if (cacheClimb.Type == CfType.ClimbIndoor) { return(ClimbIndoorDetail(id, nameUrlPart)); } else if (cacheClimb.Type == CfType.ClimbOutdoor) { return(ClimbOutdoorDetail(id, nameUrlPart)); } else { throw new Exception("ClimbDetail not a valid climb type"); } }
public ActionResult LocationOutdoorNew(string countryUrlPart, string areaNameUrlPart, LocationOutdoorNewViewModel m) { PerformLocationAddValidation(areaNameUrlPart, m.Latitude, m.Longitude, m.Name, AppLookups.Country(countryUrlPart), false); if (ModelState.IsValid) { var location = geoSvc.CreateLocationOutdoor(new LocationOutdoor() { CountryID = m.CountryID, Latitude = m.Latitude, Longitude = m.Longitude, Name = m.Name, TypeID = (byte)m.Type }); var view = mappingSvc.CreateBingView(new PlaceBingMapView() { ID = location.ID, Bounds = m.ViewOptions.Bounds, CenterOffset = m.ViewOptions.CenterOffset, Heading = m.ViewOptions.Heading, MapCenterLatitude = m.ViewOptions.MapCenterLatitude, MapCenterLongitude = m.ViewOptions.MapCenterLongitude, MapTypeId = m.ViewOptions.MapTypeId, Zoom = m.ViewOptions.Zoom }); return(Redirect(location.SlugUrl)); } else { PrepareViewDataForLocationOutdoorNew(countryUrlPart, areaNameUrlPart); return(View("LocationOutdoorNew")); } }