コード例 #1
0
ファイル: BarThreadService.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 移动帖子
        /// </summary>
        /// <param name="threadId">要移动帖子的ThreadId</param>
        /// <param name="moveToSectionId">转移到帖吧的SectionId</param>
        public void MoveThread(long threadId, long moveToSectionId)
        {
            BarThread thread = barThreadRepository.Get(threadId);

            if (thread.SectionId == moveToSectionId)
            {
                return;
            }
            long oldSectionId      = thread.SectionId;
            var  barSectionService = new BarSectionService();
            var  oldSection        = barSectionService.Get(oldSectionId);

            if (oldSection == null)
            {
                return;
            }
            var newSection = barSectionService.Get(moveToSectionId);

            if (newSection == null)
            {
                return;
            }
            barThreadRepository.MoveThread(threadId, moveToSectionId);

            CountService countService = new CountService(TenantTypeIds.Instance().BarSection());

            countService.ChangeCount(CountTypes.Instance().ThreadCount(), oldSection.SectionId, oldSection.UserId, -1, true);
            countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), oldSection.SectionId, oldSection.UserId, -1, true);

            countService.ChangeCount(CountTypes.Instance().ThreadCount(), newSection.SectionId, newSection.UserId, 1, true);
            countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), newSection.SectionId, newSection.UserId, 1, true);
        }