Beispiel #1
0
        /// <summary>
        /// Removed a user and all assocaited data from the database
        /// </summary>
        public void DeleteUserCompletely(Guid userID)
        {
            DeleteAllRelatedPartnersCallsAndReplies(userID);

            //-- Delete all posts and associated FK comments will go too from Cascade rule.
            new FeedClimberChannelRequestDA().DeleteAllRequestsForUser(userID);

            List <FeedPostComment> comments = new FeedPostCommentDA().GetUsersComments(userID);

            foreach (FeedPostComment c in comments)
            {
                new FeedPostCommentDA().Delete(c.ID);
            }

            List <FeedClimbingPost> posts = new FeedClimbingPostDA().GetUsersPosts(userID);

            foreach (FeedClimbingPost p in posts)
            {
                new FeedClimbingPostDA().Delete(p.ID);
            }

            ctx.Feedbacks.DeleteAllOnSubmit(from c in ctx.Feedbacks where c.UserID == userID select c);

            //-- Will have to build something smart here to delete a group and all it's associated childen...
            ctx.PartnerCalls.DeleteAllOnSubmit(from c in ctx.PartnerCalls where c.ClimberProfileID == userID select c);
            ctx.PartnerCallSubscriptions.DeleteAllOnSubmit(from c in ctx.PartnerCallSubscriptions where c.UserID == userID select c);

            ctx.PlaceUserClimbs.DeleteAllOnSubmit(from c in ctx.PlaceUserClimbs where c.UserID == userID select c);
            ctx.UserMessages.DeleteAllOnSubmit(from c in ctx.UserMessages where c.ReceivingUserID == userID || c.SendingUserID == userID select c);

            ctx.UserSettings.DeleteAllOnSubmit(from c in ctx.UserSettings where c.ID == userID select c);
            ctx.MessageBoardMessages.DeleteAllOnSubmit(from c in ctx.MessageBoardMessages where c.UserID == userID select c);
            ctx.ClimberProfileExtendeds.DeleteAllOnSubmit(from c in ctx.ClimberProfileExtendeds where c.ID == userID select c);

            ctx.ClimberProfiles.DeleteAllOnSubmit(from c in ctx.ClimberProfiles where c.ID == userID select c);

            //-- TODO: consider if it is worth deleting a users images?
            //-- Deal with removing the message boards and child messages too:
            //ctx.MessageBoards.DeleteAllOnSubmit(from c in ctx.MessageBoards where c. == userID select c);

            ctx.SubmitChanges(ConflictMode.FailOnFirstConflict);

            Membership.DeleteUser(Membership.GetUser(userID).UserName);
        }
 public FeedClimbingPostDA() : base()
 {
     feedPostCommentDA = new FeedPostCommentDA(ctx);
 }