/// <summary> /// /// </summary> /// <remarks>Called by the parent methods CreateClimbIndoor & CreateClimbOutdoor</remarks> private ObjectModMeta CreateClimb <T>(T obj, List <int> categories, CfType climbType, Action saveClimbToDB) where T : Climb { CreateClimbAuthorization(obj, categories); obj.ID = Guid.NewGuid(); obj.TypeID = (byte)climbType; obj.NameUrlPart = obj.Name.ToUrlFriendlyString(); if (obj.NameShort == null) { obj.NameShort = string.Empty; } if (obj.SetterID == Guid.Empty) { obj.SetterID = null; } obj.GradeCfNormalize = GradeConvert(obj.GradeLocal); //-- Add climb category/tags if (categories.Count > 0) { foreach (var c in categories) { obj.ClimbTags.Add(new ClimbTag(obj.ID, c)); } } saveClimbToDB(); var meta = objModMetaRepo.Create(new ObjectModMeta(obj, currentUser.UserID)); AppLookups.AddIndexEntryToCache(obj.ToCacheIndexEntry()); return(meta); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public LocationOutdoor CreateLocationOutdoor(LocationOutdoor obj) { var user = CfPerfCache.GetClimber(CfIdentity.UserID); CreateLocationOutdoorAuthorization(obj); obj.NameUrlPart = obj.Name.ToUrlFriendlyString(); locOutdoorRepo.Create(obj); var modPlaceDetail = objModMetaRepo.Create(new ObjectModMeta(obj, currentUser.UserID)); //-- Update the cache AppLookups.AddIndexEntryToCache(obj.ToCacheIndexEntry()); ClaimObject(obj); //-- Save post for the feed //PostService.CreateLocationCreatedPost(obj); var action = SaveModActionAndUpdateModProfile(ModActionType.LocationOutdoorAdd, null, obj, modPlaceDetail, (m, actionID) => m.SetCreated(actionID), mp => mp.PlacesAdded++, "added {0} {1}", obj.Type, obj.Name); postSvc.CreateContentAddPost(action, obj.ID, user.PrivacyPostsDefaultIsPublic); //-- Shoot off a notification to moderators return(obj); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public Area CreateArea(Area obj) { CreateAreaAuthorization(obj); var user = CfPerfCache.GetClimber(CfIdentity.UserID); obj.NameUrlPart = obj.Name.ToUrlFriendlyString(); //-- Incase we are creating a freeform area place with no suggested center (from bing / google) if (obj.Latitude == 0 & obj.Longitude == 0) { obj.Latitude = obj.Geo.EnvelopeCenter().Lat.Value; obj.Longitude = obj.Geo.EnvelopeCenter().Long.Value; } var area = areaRepo.Create(obj); var modPlaceDetail = objModMetaRepo.Create(new ObjectModMeta(area, currentUser.UserID)); //-- Update the cache AppLookups.AddIndexEntryToCache(area.ToCacheIndexEntry()); ClaimObject(obj); //-- Save post for the feed //PostService.CreateAreaCreatedPost(currentUser.UserID, area); var action = SaveModActionAndUpdateModProfile(ModActionType.AreaAdd, null, obj, modPlaceDetail, (m, actionID) => m.SetCreated(actionID), mp => mp.PlacesAdded++, "added {0} {1}", area.Type, area.Name); postSvc.CreateContentAddPost(action, obj.ID, user.PrivacyPostsDefaultIsPublic); //-- Shoot off a notification to moderators //-- Calculate all areas that completely contain this area // var moderatorsToNotify = new List<ModProfile>(); // var areasContainingThisArea = ??? // foreach (var area in areasContainingThisArea) { // var modsWatchingArea = modProfileRepo.GetPlacesModerators(area.ID); // moderatorsToNotify.Add(modsWatchingArea); //} // foreach (var mod in moderatorsToNotify) { NotifyModeratorOfAreaCreated(mod); } return(area); }