Пример #1
0
        /// <summary>
        /// 删除用户记录(删除用户时使用)
        /// </summary>
        /// <param name="userId">被删除用户</param>
        /// <param name="takeOverUserName">接管用户名</param>
        /// <param name="takeOverAll">是否接管被删除用户的所有内容</param>
        public void DeleteUser(long userId, string takeOverUserName, bool takeOverAll)
        {
            long              takeOverUserId    = UserIdToUserNameDictionary.GetUserId(takeOverUserName);
            IUserService      userService       = DIContainer.Resolve <IUserService>();
            User              takeOver          = userService.GetFullUser(takeOverUserId);
            BarSectionService barSectionService = new BarSectionService();
            BarThreadService  barThreadService  = new BarThreadService();
            BarPostService    barPostService    = new BarPostService();

            //删除用户时,不删除贴吧,把贴吧转让,如果没有指定转让人,那就转给网站初始管理员
            if (takeOver == null)
            {
                takeOverUserId = new SystemDataService().GetLong("Founder");
                takeOver       = userService.GetFullUser(takeOverUserId);
            }

            barThreadRepository.DeleteUser(userId, takeOver, takeOverAll);
            if (takeOver != null)
            {
                if (!takeOverAll)
                {
                    barThreadService.DeletesByUserId(userId);
                    barPostService.DeletesByUserId(userId);
                }
            }
            //else
            //{
            //    barSectionService.DeletesByUserId(userId);
            //    barThreadService.DeletesByUserId(userId);
            //    barPostService.DeletesByUserId(userId);
            //}
        }