예제 #1
0
        /// <summary>
        /// 删除贴吧
        /// </summary>
        /// <param name="aid">贴吧编号</param>
        public void RemoveForumByKey(Guid aid)
        {
            IRepository <TopForumThread> tftRep = Factory.Factory <IRepository <TopForumThread> > .GetConcrete <TopForumThread>();

            IRepository <Forum> forumRep = FBS.Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>();

            IRepository <ForumThread> threadRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            // IForumThreadRepository threadRep = Factory.Factory<IForumThreadRepository>.GetConcrete<ForumThread>();

            //IRepository<ForumMessageReply> msgrRep = Factory.Factory<IRepository<ForumMessageReply>>.GetConcrete<ForumMessageReply>();
            IRepository <ThreadRootMessage> trmRep = Factory.Factory <IRepository <ThreadRootMessage> > .GetConcrete <ThreadRootMessage>();

            IList <ThreadRootMessage> trmList = trmRep.FindAll(new Specification <ThreadRootMessage>(t => t.Forum == aid));

            if (trmList != null)
            {
                foreach (ThreadRootMessage trm in trmList)
                {
                    trmRep.Remove(trm);
                }
                trmRep.PersistAll();
            }
            IRepository <ForumMessageReply> fmrRep = Factory.Factory <IRepository <ForumMessageReply> > .GetConcrete <ForumMessageReply>();

            IList <ForumMessageReply> fmrList = fmrRep.FindAll(new Specification <ForumMessageReply>(f => f.Forum == aid));

            if (fmrList != null)
            {
                foreach (ForumMessageReply fmr in fmrList)
                {
                    fmrRep.Remove(fmr);
                }
                fmrRep.PersistAll();
            }

            IList <ForumThread> fThreadList = threadRep.FindAll(new Specification <ForumThread>(ft => ft.ForumID == aid));

            if (fThreadList != null)
            {
                foreach (ForumThread ft in fThreadList)
                {
                    threadRep.RemoveByKey(ft.Id);
                    TopForumThread tft = tftRep.Find(new Specification <TopForumThread>(tftha => tftha.TopForumThreadID == ft.Id));
                    if (null != tft)
                    {
                        tftRep.Remove(tft);
                        tftRep.PersistAll();
                    }
                }
                threadRep.PersistAll();
            }



            forumRep.Remove(forumRep.GetByKey(aid));
            forumRep.PersistAll();
        }
예제 #2
0
        /// <summary>
        /// 创建置顶帖
        /// </summary>
        /// <param name="model">新建置顶帖模型</param>
        public void CreateTopForumThread(Guid id, string type)
        {
            IRepository <TopForumThread> rep = Factory.Factory <IRepository <TopForumThread> > .GetConcrete <TopForumThread>();

            //IRepository<TopForumThread> readRep = Factory.Factory<IRepository<TopForumThread>>.GetConcrete();
            IForumThreadRepository forumThreadRep = FBS.Factory.Factory <IForumThreadRepository> .GetConcrete();

            // ForumThread t = forumThreadRep.Find(new Specification<ForumThread>(s=>s.Id==id));
            ForumThread t = null;

            t = forumThreadRep.GetByKey(id);
            //NewTopForumThreadModel model = new NewTopForumThreadModel() { CreatTime = DateTime.Now, TopForumID = t.ForumID, TopForumThreadID = t.Id };
            if (type == "static")
            {
                TopForumThread tf = new TopForumThread(t.Id);
                try
                {
                    //rep.Add(new TopForumThread(Guid.NewGuid(),model.TopForumThreadID,model.TopForumID));
                    rep.Add(tf);
                    rep.PersistAll();
                }
                catch { }
            }
            else if (type == "onlyforum")
            {
                TopForumThread tf = new TopForumThread(t.Id, t.ForumID);
                try
                {
                    //rep.Add(new TopForumThread(Guid.NewGuid(),model.TopForumThreadID,model.TopForumID));
                    rep.Add(tf);
                    rep.PersistAll();
                }
                catch { }
            }
            else if (type == "cancel")
            {
                TopForumThread tf = rep.Find(new Specification <TopForumThread>(tft => tft.TopForumThreadID == id));
                try
                {
                    //rep.Add(new TopForumThread(Guid.NewGuid(),model.TopForumThreadID,model.TopForumID));
                    rep.Remove(tf);
                    rep.PersistAll();
                }
                catch { }
            }
        }