Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public void DeleteArea(Area obj)
        {
            var meta = DeleteAreaAuthorization(obj);

            //-- TODO: Shoot off notifications

            areaRepo.Delete(obj);

            //-- Update the cache
            AppLookups.RemoveCacheIndexEntry(obj.ID);

            var modWhoAddedArea = modProfileRepo.GetByID(meta.CreatedByUserID);

            if (modWhoAddedArea.PlacesAdded > 0)
            {
                modWhoAddedArea.PlacesAdded--;
                modProfileRepo.Update(modWhoAddedArea);

                //-- Remove the points associated with this place
                var actionsWithPoints = modActionRepo.GetAll().Where(a => a.OnObjectID == meta.ID);
                ReverseActions(actionsWithPoints);
            }

            //-- update the principal details with the details we just updated (if they are the same person who deleted it)
            CfPrincipal.AttachModProfile(modProfileRepo.GetByID(currentUser.UserID));

            meta.Name = obj.VerboseDisplayName;

            var action = SaveModActionAndUpdateModProfile(ModActionType.AreaDelete, obj, null, meta,
                                                          (m, actionID) => m.SetDeleted(actionID), null, "deleted {0} {1}", obj.Type, obj.Name);

            postSvc.DeleteContentAddPost(action);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>Called by the parent methods CreateClimbIndoor & CreateClimbOutdoor</remarks>
        private void DeleteClimb(Climb obj)
        {
            climbRepo.Delete(obj.ID);

            //-- Remove from the cache
            AppLookups.RemoveCacheIndexEntry(obj.ID);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public void DeleteLocationIndoor(LocationIndoor obj)
        {
            var meta = DeleteLocationIndoorAuthorization(obj);

            locIndoorRepo.Delete(obj.ID);

            //-- Update the cache
            AppLookups.RemoveCacheIndexEntry(obj.ID);

            var modWhoAddedArea = modProfileRepo.GetByID(meta.CreatedByUserID);

            if (modWhoAddedArea.PlacesAdded > 0)
            {
                modWhoAddedArea.PlacesAdded--;
                modProfileRepo.Update(modWhoAddedArea);

                //-- Remove the points associated with this place
                var actionsWithPoints = modActionRepo.GetAll().Where(a => a.OnObjectID == meta.ID);
                ReverseActions(actionsWithPoints);
            }

            //-- update the principal details with the details we just updated (if they are the same person who deleted it)
            CfPrincipal.AttachModProfile(modProfileRepo.GetByID(currentUser.UserID));

            //-- Incase the name changed during the life of the object, we want to save the meta with the same name as the object was when it was deleted.
            meta.Name = obj.VerboseDisplayName;

            var action = SaveModActionAndUpdateModProfile(ModActionType.LocationIndoorDelete, obj, null, meta,
                                                          (m, actionID) => m.SetDeleted(actionID), null, "deleted {0} {1}", obj.Type, obj.Name);

            postSvc.DeleteContentAddPost(action);
        }