public ActionResult Edit(Guid id) { CfCacheIndexEntry place = AppLookups.GetCacheIndexEntry(id); if (place == null) { return(new PlacesController().PlaceNotFound()); } else if (place.Type == CfType.ClimbIndoor) { return(RedirectToAction("ClimbIndoorEdit", new { id = id })); } else if (place.Type == CfType.ClimbOutdoor) { return(RedirectToAction("ClimbOutdoorEdit", new { id = id })); } else { var category = place.Type.ToPlaceCateogry(); if (category == PlaceCategory.Area) { return(RedirectToAction("AreaEdit", new { id = id })); } else if (category == PlaceCategory.IndoorClimbing) { return(RedirectToAction("LocationIndoorEdit", new { id = id })); } else if (category == PlaceCategory.OutdoorClimbing) { return(RedirectToAction("LocationOutdoorEdit", new { id = id })); } throw new Exception(string.Format("Category [{0}] from place [{1}][2] not supported by moderate edit", category, place.Name, place.IDstring)); } }
private void UpdateRatedObject(Guid id, List <Opinion> allOpinions) { var cacheEntry = AppLookups.GetCacheIndexEntry(id); if (cacheEntry.Type == CfType.ClimbOutdoor || cacheEntry.Type == CfType.ClimbIndoor) { UpdateOpinion <ClimbRepository, Climb>(id, allOpinions); } else if (cacheEntry.Type == CfType.ClimbingArea || cacheEntry.Type == CfType.Province || cacheEntry.Type == CfType.City) { UpdateOpinion <AreaRepository, Area>(id, allOpinions); } else if (cacheEntry.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing) { UpdateOpinion <LocationIndoorRepository, LocationIndoor>(id, allOpinions); } else if (cacheEntry.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing) { UpdateOpinion <LocationOutdoorRepository, LocationOutdoor>(id, allOpinions); } else { throw new NotImplementedException("UpdateRatedObject does not yet support type : " + cacheEntry.Type.ToString()); } }
public CheckIn CreateCheckIn(CheckIn visit) { var user = usrRepo.GetByID(CfIdentity.UserID); var place = AppLookups.GetCacheIndexEntry(visit.LocationID); if (place == null) { throw new ArgumentException("Unable to check in - No location found for " + visit.LocationID); } visit.ID = Guid.NewGuid(); visit.UserID = user.ID; if (visit.Latitude.HasValue && visit.Longitude.HasValue) { //-- It's a verified check-in, let's do something } //-- TODO check the person isn't checking in again within 1 hour to the same location var ci = checkInRepo.Create(visit); postSvc.CreateCheckInPost(ci, user.PrivacyPostsDefaultIsPublic); if (!user.PlaceMostRecentUtc.HasValue || ci.Utc > user.PlaceMostRecentUtc.Value) { user.PlaceMostRecent = visit.LocationID; user.PlaceMostRecentUtc = visit.Utc; usrRepo.Update(user); } return(ci); }
public Message GetLocation(string id) { SvcContext ctx = InflateContext(); if (ctx.Invalid) { return(ctx.ContextMessage); } Guid locID = Guid.ParseExact(id, "N"); //-- TODO, check cache var loc = AppLookups.GetCacheIndexEntry(locID); if (loc.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing) { var l = geoSvc.GetLocationIndoorByID(loc.ID); return(ReturnAsJson(new LocationIndoorDetailDto(l))); } else if (loc.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing) { var l = geoSvc.GetLocationOutdoorByID(loc.ID); return(ReturnAsJson(new LocationOutdoorDetailDto(l))); } else { return(Failed("Service not invoked correctly - ID not valid for operation")); } }
public ActionResult PlaceAjaxRefresh(Guid id) { var posts = new List <PostRendered>(); var postType = GetPostTypeFromQueryString(); if (id == Guid.Empty) { posts = postSvc.GetPostForEverywhere(postType, ClientAppType.CfWeb); } else if (id == Stgs.MyFeedID) { posts = postSvc.GetUsersFeed(CfIdentity.UserID, postType, ClientAppType.CfWeb).Posts; } else { var place = AppLookups.GetCacheIndexEntry(id); if (place.Type.ToPlaceCateogry() == PlaceCategory.Area) { posts = postSvc.GetPostForArea(id, postType, ClientAppType.CfWeb); } else { posts = postSvc.GetPostForLocation(id, postType, ClientAppType.CfWeb); } } return(PartialView("Partials/FeedPostList", new FeedPostListViewData() { FeedPosts = posts, UserHasDeletePostRights = CfPrincipal.IsGod() })); }
/// <summary> /// Get distinct, no-null list of deduc CacheIndexEntry for a given set of place ids /// </summary> /// <param name="placeIDs"></param> /// <returns></returns> private List <CfCacheIndexEntry> GetGeoDeducPlaces(IEnumerable <Guid> placeIDs) { var geoDeduciblePlaces = new List <CfCacheIndexEntry>(); foreach (var id in placeIDs) { var place = CfCacheIndex.Get(id); if (place != null) { //-- Have to add if check for opinions of provinces bug if (place.Type == CfType.Province) { geoDeduciblePlaces.Add(place); } else { geoDeduciblePlaces.AddRange(CfPerfCache.GetGeoDeduciblePlaces(place)); } } } var feedPlaceIDs = geoDeduciblePlaces.Select(p => p.ID).Distinct().ToList(); return((from c in feedPlaceIDs where AppLookups.GetCacheIndexEntry(c) != null select AppLookups.GetCacheIndexEntry(c)).ToList()); }
public Message GetClimbsOfLocationAtCheckIn(string id) { SvcContext ctx = InflateContext(); if (ctx.Invalid) { return(ctx.ContextMessage); } try { Guid ciID = Guid.ParseExact(id, "N"); var ci = new VisitsService().GetCheckInById(ciID); if (ci == null) { throw new Exception("Visit does not exist, it may have been deleted."); } ////-- TODO, check cache var loc = AppLookups.GetCacheIndexEntry(ci.LocationID); var dto = GetClimbsOfLocation(loc, ci.Utc); return(ReturnAsJson(dto)); } catch (Exception ex) { return(Failed("Could not get climbs for visit: " + ex.Message)); } }
public Message GetClimb(string id) { SvcContext ctx = InflateContext(); if (ctx.Invalid) { return(ctx.ContextMessage); } Guid climbID = Guid.ParseExact(id, "N"); ////-- TODO, check cache var climb = AppLookups.GetCacheIndexEntry(climbID); if (climb.Type == CfType.ClimbIndoor) { var c = geoSvc.GetIndoorClimbByID(climb.ID); return(ReturnAsJson(new ClimbIndoorDetailDto(c))); } else if (climb.Type == CfType.ClimbOutdoor) { var c = geoSvc.GetOutdoorClimbByID(climb.ID); return(ReturnAsJson(new ClimbOutdoorDetailDto(c))); } else { return(Failed("Service not invoked correctly - ID not valid for operation")); } }
public Message GetUsersOpinions(string id) { SvcContext ctx = InflateContext(); if (ctx.Invalid) { return(ctx.ContextMessage); } Guid userID = Guid.ParseExact(id, "N"); var dto = new List <OpinionDto>(); var latestOpinions = new ContentService().GetUsersLatestOpinions(userID, 30); var profile = CfPerfCache.GetClimber(userID); foreach (var m in latestOpinions) { var obj = AppLookups.GetCacheIndexEntry(m.ObjectID); if (obj != null) { dto.Add(new OpinionDto(m.ID, m.Rating, m.Utc, obj.Name, m.UserID, profile.Avatar, m.Comment)); } } return(ReturnAsJson(dto)); }
public Message LeaveOpinion(string id, string rating, string comment) { SvcContext ctx = InflateContext(); if (ctx.Invalid) { return(ctx.ContextMessage); } try { var objID = Guid.ParseExact(id, "N"); var obj = AppLookups.GetCacheIndexEntry(objID); var opinion = new ContentService().CreateOpinion(new Opinion() { Comment = comment, ObjectID = obj.ID, Rating = byte.Parse(rating) }, obj.ID); var by = CfPerfCache.GetClimber(CfIdentity.UserID); var dto = new OpinionDto(opinion, by); return(ReturnAsJson(dto)); } catch (Exception ex) { return(Failed("Opinion failed : " + ex.Message)); } }
public ActionResult SubscriptionSuggestion(Guid id) { var place = AppLookups.GetCacheIndexEntry(id); ViewBag.Place = place; return(View()); }
public ActionResult UnclaimPage(Guid id) { var p = AppLookups.GetCacheIndexEntry(id); geoSvc.UnclaimObject(p); return(RedirectToAction("Index")); }
public ActionResult Detail(Guid id) { var pc = pcSvc.GetPartnerCallById(id); if (pc != null) { ViewBag.PartnerCall = pc; var place = AppLookups.GetCacheIndexEntry(pc.PlaceID); var model = PrepareNewCallViewData(place); ViewBag.Post = new PostService().GetPostByID(id); ViewBag.PlaceEntry = place; return(View(model)); } else { var pcwi = pcSvc.GetPartnerCallWorkItemByPartnerCallId(id); if (pcwi == null) { return(View("PageNotFound")); } else { return(RedirectToRoute("UserProfile", new { id = pcwi.OnBehalfOfUserID })); } } }
/// <summary> /// /// </summary> /// <param name="ci"></param> /// <returns></returns> internal Post CreateCheckInPost(CheckIn ci, bool isPublic) { var place = AppLookups.GetCacheIndexEntry(ci.LocationID); var postMgr = new cf.Content.Feed.V1.CheckInPostManager(); dynamic data = postMgr.CreateTemplateDynamicData(ci, place); return(postMgr.CreatePost(ci.ID, ci.UserID, ci.Utc, place, isPublic, data)); }
/// <summary> /// /// </summary> /// <param name="o"></param> /// <param name="placeID"></param> /// <param name="isPrivate"></param> /// <returns></returns> internal Post CreateOpinionPost(Opinion o, Guid placeID, bool isPublic) { var place = AppLookups.GetCacheIndexEntry(placeID); var postMgr = new cf.Content.Feed.V0.OpinionPostManager(); dynamic data = postMgr.CreateTemplateDynamicData(o, GetPostPlace(o.ObjectID)); return(postMgr.CreatePost(o.ID, o.UserID, place, isPublic, data)); }
/// <summary> /// /// </summary> /// <param name="userID"></param> /// <param name="area"></param> /// <returns></returns> public Post CreateTalkPost(Guid placeID, string comment) { var place = AppLookups.GetCacheIndexEntry(placeID); var postMgr = new cf.Content.Feed.V0.TalkPostManager(); dynamic data = postMgr.CreateTemplateDynamicData(new { Comment = comment, Place = place }); return(postMgr.CreatePost(Guid.NewGuid(), CfIdentity.UserID, place, true, data)); }
public ActionResult ActionPlaceList(Guid id) { var place = AppLookups.GetCacheIndexEntry(id); var modPlace = geoSvc.GetObjectModeMeta(id); ViewBag.ModActions = geoSvc.GetModeratorActionsOnObject(id); ViewBag.ModPlace = modPlace; ViewBag.Place = place; return(View()); }
public ActionResult New(Guid id) { var place = AppLookups.GetCacheIndexEntry(id); //-- Return PlaceNotFound //if (place == null) { return } var model = PrepareNewCallViewData(place); return(View("New", model)); }
public static MvcHtmlString PlaceLink(this HtmlHelper helper, Guid placeID) { var place = AppLookups.GetCacheIndexEntry(placeID); if (place == null) { return(new MvcHtmlString("")); } return(new MvcHtmlString(string.Format(@"<a href=""{0}"">{1}</a>", place.SlugUrl, place.Name))); }
public ActionResult PlaceIdRedirect(Guid id) { var place = AppLookups.GetCacheIndexEntry(id); if (place == null) { return(PlaceNotFound()); } else { return(RedirectPermanent(place.SlugUrl)); } }
public ActionResult ListUser(Guid id) { var usersPartnerCalls = pcSvc.GetUsersPartnerCalls(id).OrderByDescending(o => o.CreatedUtc).ToList(); ViewBag.PartnerCalls = usersPartnerCalls; ViewBag.User = new UserService().GetProfileByID(id); var distinctPlaceIDs = (from c in usersPartnerCalls select c.PlaceID).Distinct();; ViewBag.Places = (from c in distinctPlaceIDs where AppLookups.GetCacheIndexEntry(c) != null select AppLookups.GetCacheIndexEntry(c)).Take(10).ToList(); return(View()); }
public static MvcHtmlString PlaceLinkWithBlank(this HtmlHelper helper, Guid placeID) { var place = AppLookups.GetCacheIndexEntry(placeID); if (place == null && placeID != Guid.Empty) { return(new MvcHtmlString("<i>item deleted</i>")); } else if (place == null) { return(new MvcHtmlString("")); } return(new MvcHtmlString(string.Format(@"<a href=""{0}"" target=""_blank"">{1}</a>", place.SlugUrl, place.Name))); }
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 IList <Climb> GetClimbsOfLocationForLogging(Guid id, DateTime checkInDateTime) { var loc = AppLookups.GetCacheIndexEntry(id); if (loc.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing) { return(climbRepo.GetIndoorClimbsOfLocation(id).Where(c => (!c.SetDate.HasValue || c.SetDate < checkInDateTime) && (!c.DiscontinuedDate.HasValue || (c.DiscontinuedDate.Value > checkInDateTime))).ToClimbList()); } else { return(climbRepo.GetAll().Where(c => c.LocationID == id).ToList()); } }
public ActionResult ClimbNew(Guid id) { var cacheLoc = AppLookups.GetCacheIndexEntry(id); if (cacheLoc.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing) { return(RedirectToAction("ClimbIndoorNew", new { id = id })); } else if (cacheLoc.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing) { return(ClimbOutdoorNew(id)); } else { throw new Exception("ClimbNew not a valid climb type"); } }
public ActionResult ClimbEdit(Guid id) { var cachedClimb = AppLookups.GetCacheIndexEntry(id); if (cachedClimb.Type == CfType.ClimbIndoor) { return(ClimbIndoorEdit(id)); } else if (cachedClimb.Type == CfType.ClimbOutdoor) { return(ClimbOutdoorEdit(id)); } else { throw new Exception("ClimbEdit not a valid climb type"); } }
public ActionResult AddMediaTag(Guid id, Guid onObjectID) { var media = mediaSvc.GetMediaByID(id); var obj = AppLookups.GetCacheIndexEntry(onObjectID); var alreadyTagged = media.ObjectMedias.Where(om => om.OnOjectID == onObjectID).Count() > 0; if (media != null && obj != null && !alreadyTagged) { mediaSvc.AddMediaTag(media, onObjectID); return(Json(new { Success = true })); } else { return(Json(new { Success = false })); } }
public ActionResult SubscriptionNew(Guid id) { var place = AppLookups.GetCacheIndexEntry(id); PrepareNewCallViewData(place); var model = new NewPartnerCallSubscriptionViewModel() { ParnterCallPlaceID = place.ID, ForIndoor = true, ForOutdoor = true, EmailRealtime = true, MobileRealtime = true, ExactOnly = false }; return(View(model)); }
public static MvcHtmlString PlaceLinkShortName(this HtmlHelper helper, Guid placeID) { var place = AppLookups.GetCacheIndexEntry(placeID); if (place == null) { return(new MvcHtmlString("")); } var name = place.Name; if (!string.IsNullOrEmpty(place.NameShort)) { name = place.NameShort; } return(new MvcHtmlString(string.Format(@"<a href=""{0}"">{1}</a>", place.SlugUrl, name))); }
public ActionResult Add(Guid id) { var obj = AppLookups.GetCacheIndexEntry(id); if (obj == null) { PlaceNotFound(); } var model = new AddViewModel() { ObjectId = id, ObjectSlug = obj.SlugUrl, ObjectName = obj.Name, Title = "Climbing media of " + obj.Name, ChooseFromExisting = true }; ViewBag.MyMedia = mediaSvc.GetMediaByUserWithObjectRefereces(CfIdentity.UserID).ToList(); return(View(model)); }