Exemplo n.º 1
0
        public bool deletePost(User u, Post p)
        {
            IList <SubForum> subs  = u.forum.SubForum;
            SubForum         s     = null;
            Post             toDel = null;

            for (int i = 0; i < subs.Count; i++)
            {
                foreach (Post thread in subs.ElementAt(i).MyThreads)
                {
                    toDel = IsCommentof(p.Id, thread);
                    if (toDel != null)
                    {
                        s = subs.ElementAt(i);
                        break;
                    }
                }
            }
            bool isAdmin = false;

            if ((u is Member))
            {
                Member mem = (Member)u;
                isAdmin = mem.Getstate() is Admin;
            }
            if ((u is Member) && (((Member)u).MemberPosts.Contains(toDel)) || isAdmin)
            {
                bool b = s.removePost(toDel);
                //b |= toDel.kill();
                if (s != null)
                {
                    rep.Update <SubForum>(s);
                }
                rep.Update <User>(toDel.owner);
                rep.Update <Forum>(u.forum);
                rep.Remove <Post>(toDel);
                return(b);
            }
            else
            {
                System.Console.Write("cant delete post  u isnt a member or not own the delete");
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool deletePost(User u, Post p)
        {
            IList <SubForum> subs = u.forum.getSubForum();
            SubForum         s    = null;

            for (int i = 0; i < subs.Count; i++)
            {
                if (subs[i].GetMyThreads().Contains(p))
                {
                    s = subs[i];
                    break;
                }
            }
            bool isAdmin = false;

            if ((u is Member))
            {
                Member mem = (Member)u;
                isAdmin = mem.Getstate() is Admin;
            }
            if ((u is Member) && (((Member)u).MemberPosts.Contains(p)) || isAdmin)
            {
                bool b = ((Member)u).delPost(p) && s.removeThread(p);
                if (s != null)
                {
                    rep.Update <SubForum>(s);
                }
                rep.Update <User>(p.owner);
                rep.Update <Forum>(u.forum);
                //                rep.Remove<Post>(p);
                return(b);
            }
            else
            {
                System.Console.Write("cant delete post  u isnt a member or not own the delete");
                return(false);
            }
        }