public ActionResult AreaEdit(Guid id) { //-- TODO Put error check var area = geoSvc.GetAreaByID(id); if (area == null) { return new PlacesController().PlaceNotFound(); } ViewBag.Area = area; var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + id.ToString(); var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + id, 680, 400, geoJsonUrl); mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID)); ViewBag.PlaceTypeDropDownList = cf.Web.Mvc.ViewData.SelectLists.GetAreaTypeSelectList(false); ViewBag.MapImageToDisplayUrl = (area.AvatarRelativeUrl != string.Empty) ? Stgs.ImgsRt + area.AvatarRelativeUrl : Stgs.DefaultMapInfoImage; var mapItems = new MappingService().GetAreaEditMapItems(area); ViewBag.MapItemsArea = mapItems.Items[0]; mapItems.Items.RemoveAt(0); ViewBag.MapItemsLocations = mapItems.Items; return View(new AreaEditViewModel() { ID = area.ID, WKT = area.Geo.GetWkt(), GeoReduceThreshold = area.GeoReduceThreshold, SearchSupportString = area.SearchSupportString, PlaceType = area.Type.ToString(), Name = area.Name, NameShort = area.NameShort, NameUrlPart = area.NameUrlPart, Description = area.Description, NoIndoorConfirmed = area.NoIndoorConfirmed, MapModel = mapModel }); }
public ActionResult AreaEdit(Guid id, AreaEditViewModel m) { var area = geoSvc.GetAreaByID(id); var original = area.GetCloneWithGeo(); if (ModelState.IsValid) { area.TypeID = (byte)Enum.Parse(typeof(CfType), m.PlaceType); area.SearchSupportString = m.SearchSupportString ?? ""; area.GeoReduceThreshold = m.GeoReduceThreshold; area.Geo = SqlGeography.Parse(new SqlString(m.WKT)); area.Name = m.Name; area.NameUrlPart = m.NameUrlPart; area.NameShort = m.NameShort; area.NoIndoorConfirmed = m.NoIndoorConfirmed; area.Description = m.Description; SaveBing7MapViewFromModel(m.MapModel.ViewOptions, area.ID); geoSvc.UpdateArea(original, area); return Redirect(area.SlugUrl); } else { ViewBag.Area = area; var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + id.ToString(); var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + id, 680, 400, geoJsonUrl); mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID)); ViewBag.MapModel = mapModel; ViewBag.PlaceTypeDropDownList = SelectLists.GetAreaTypeSelectList(false); return View(m); } }
public ActionResult CountryDetail(string countryUrlPart) { ViewBag.Current = country; ViewBag.Provinces = AppLookups.CountrysProvinces(country.ID); var areas = geoSvc.GetCitiesAndMajorClimbingAreasOfCountry(country.ID); ViewBag.Cities = areas.Where(a => a.Type == CfType.City).ToList().RandomSample(12); var climbingAreas = areas.Where(a => a.Type == CfType.ClimbingArea).ToList(); ViewBag.ClimbingAreas = climbingAreas.RemoveAllChildAreas().RandomSample(12); var geoJsonUrl = Stgs.MapSvcRelativeUrl + "country/" + countryUrlPart; var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + countryUrlPart, 730, 460, geoJsonUrl) { MapTypeId = "road" }; mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetCustomCountryBingMapView(country)); ViewBag.MapModel = mapModel; ViewBag.TopClimbs = geoSvc.GetTopClimbOfCountry(country.ID, 24); ViewBag.TopLocations = geoSvc.GetTopLocationsOfCountry(country.ID); return View("CountryDetail"); }
public ActionResult CityDetail(Area area, IEnumerable<Location> locationsOfArea) { ViewBag.TopOutdoorLocations = locationsOfArea.Where(c => c.IsOutdoorClimbing).OrderByDescending(l => l.Rating).Take(12).ToList(); var relatedAreas = geoSvc.GetRelatedAreas(area); ViewBag.Provinces = relatedAreas.Where(a => a.Type == CfType.Province).ToList(); var relatedClimbingAreas = relatedAreas.Where(c => c.Type == CfType.ClimbingArea).ToList(); var climbingAreas = area.GetIntersectingAreas(relatedClimbingAreas); ViewBag.ClimbingAreas = climbingAreas; var nearbyAreas = area.GetNonIntersectingAreas(relatedClimbingAreas).RemoveAllChildAreas(); ViewBag.NearbyClimbingAreas = nearbyAreas; var geoJsonUrl = Stgs.MapSvcRelativeUrl + "city/" + area.ID.ToString(); var mapModel = new Bing7GeoJsonMapViewModel("rock-climbing-map-" + area.NameUrlPart, 730, 420, geoJsonUrl); if (area.Type != CfType.Province) { mapModel.SetInvisiblePolygons(); } mapModel.ViewOptions = ViewBag.MapView; ViewBag.MapModel = mapModel; return View("CityDetail"); }
public AreaEditViewModel() { //-- This is required for model binding on edit else there is an exception MapModel = new Bing7GeoJsonMapViewModel(); }
private NewPartnerCallViewModel PrepareNewCallViewData(CfCacheIndexEntry place) { var m = new NewPartnerCallViewModel() { ParnterCallPlaceID = place.ID, ForIndoor = true, ForOutdoor = true }; if (place.Type == CfType.Country) { ViewBag.PlaceDisallowed = true; ViewBag.Place = place; } else if (place.Type == CfType.Province) { var area = geoSvc.GetAreaByID(place.ID); ViewBag.PlaceDisallowed = true; ViewBag.Place = place; ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList(); } else if (place.Type.ToPlaceCateogry() == PlaceCategory.Area) { ViewBag.PlaceType = "Area"; var area = geoSvc.GetAreaByID(place.ID); ViewBag.Place = area; if (area.DisallowPartnerCalls) { ViewBag.PlaceDisallowed = true; } else { var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + place.ID.ToString(); var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + place.ID, 680, 400, geoJsonUrl); mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID)); var mapItems = new MappingService().GetAreaEditMapItems(area); ViewBag.MapItemsArea = mapItems.Items[0]; mapItems.Items.RemoveAt(0); ViewBag.MapItemsLocations = mapItems.Items; ViewBag.MapModel = mapModel; } ViewBag.ChildLocations = geoSvc.GetGeoDeduciblePlaces(place).Where(p=>p.Type.IsLocation()); ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList(); } else if (place.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing || place.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing) { ViewBag.PlaceType = "Location"; var location = geoSvc.GetLocationByID(place.ID); ViewBag.Place = location; if (location.IsIndoorClimbing) { m.ForOutdoor = false; } if (location.IsOutdoorClimbing) { m.ForIndoor = false; } var mapModel = new Bing7MapWithLocationViewModel(location.NameUrlPart, 732, 340, location.Latitude, location.Longitude, location.AvatarRelativeUrl); var mapViewSettings = mappingSvc.GetBingViewByID(location.ID); if (mapViewSettings == default(PlaceBingMapView)) { mapViewSettings = PlaceBingMapView.GetDefaultIndoorSettings(location); } mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mapViewSettings); ViewBag.LocationMapView = mapModel; ViewBag.InterectingAreas = geoSvc.GetIntersectingAreasOfPoint(location.Latitude, location.Longitude) .Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList(); } else { throw new ArgumentException("Place type [" + place.Type.ToString() + "] not supported for partner calls"); } return m; }