public IList<Climb> LogClimbAuthorize(CheckIn checkIn, LoggedClimb log) { //-- (JSK 2011:09.11) Don't think it makes sense to cache this: //var validClimbs = PerfCache.GetClimbsForCheckIn(checkIn.LocationID, checkIn.Utc); var validClimbs = new GeoService().GetClimbsOfLocationForLogging(checkIn.LocationID, checkIn.Utc); if (checkIn.UserID != CfIdentity.UserID) { var error = string.Format("Cannot log climbs for CheckIn with ID[{0}] because it does not belong to the current logged in user[{1}]", checkIn.ID, CfIdentity.UserID); throw new ArgumentException(error); } try { ClimbExperience experience = (ClimbExperience)log.Experince; ClimbGradeOpinion oppinion = (ClimbGradeOpinion)log.GradeOpinion; ClimbOutcome outcome = (ClimbOutcome)log.Outcome; } catch (Exception ex) { throw new ArgumentException(ex.Message); } if (log.Rating < 0 || log.Rating > 5) { throw new ArgumentException("Rating must be between 0 and 5."); } var climb = validClimbs.Where(c => c.ID == log.ClimbID).SingleOrDefault(); if (climb == default(Climb)) { var error = string.Format("Climb with ID[{0}] is not a valid climb to log @ {1} on {2}", log.ClimbID, AppLookups.GetCacheIndexEntry(checkIn.LocationID).Name, checkIn.Utc); throw new ArgumentException(error); } return validClimbs; }
public IList <Climb> LogClimbAuthorize(CheckIn checkIn, LoggedClimb log) { //-- (JSK 2011:09.11) Don't think it makes sense to cache this: //var validClimbs = PerfCache.GetClimbsForCheckIn(checkIn.LocationID, checkIn.Utc); var validClimbs = new GeoService().GetClimbsOfLocationForLogging(checkIn.LocationID, checkIn.Utc); if (checkIn.UserID != CfIdentity.UserID) { var error = string.Format("Cannot log climbs for CheckIn with ID[{0}] because it does not belong to the current logged in user[{1}]", checkIn.ID, CfIdentity.UserID); throw new ArgumentException(error); } try { ClimbExperience experience = (ClimbExperience)log.Experince; ClimbGradeOpinion oppinion = (ClimbGradeOpinion)log.GradeOpinion; ClimbOutcome outcome = (ClimbOutcome)log.Outcome; } catch (Exception ex) { throw new ArgumentException(ex.Message); } if (log.Rating < 0 || log.Rating > 5) { throw new ArgumentException("Rating must be between 0 and 5."); } var climb = validClimbs.Where(c => c.ID == log.ClimbID).SingleOrDefault(); if (climb == default(Climb)) { var error = string.Format("Climb with ID[{0}] is not a valid climb to log @ {1} on {2}", log.ClimbID, AppLookups.GetCacheIndexEntry(checkIn.LocationID).Name, checkIn.Utc); throw new ArgumentException(error); } return(validClimbs); }
public ActionResult LocationOutdoorEdit(Guid id) { var location = new GeoService().GetLocationOutdoorByID(id); if (location == null) { return new PlacesController().PlaceNotFound(); } ViewBag.Location = location; var climbImageToDisplay = (location.AvatarRelativeUrl != string.Empty) ? Stgs.ImgsRt + location.AvatarRelativeUrl : Stgs.DefaultMapInfoImage; ViewBag.ClimbingImageToDisplayUrl = climbImageToDisplay; var model = new LocationOutdoorEditViewModel(); model.InjectFrom(location); var mapView = mappingSvc.GetBingViewByID(location.ID); model.MapView = new Bing7MapWithLocationViewModel("myMap", 650, 340, location.Latitude, location.Longitude, climbImageToDisplay); model.MapView.ViewOptions = new Bing7MapViewOptionsViewModel(mapView); return View(model); }
public ActionResult LocationOutdoorDelete(Guid id) { var l = new GeoService().GetLocationOutdoorByID(id); geoSvc.DeleteLocationOutdoor(l); return RedirectToAction("LocationsOutdoor"); }
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); } }