Exemple #1
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static StopedUser New()
        {
            StopedUser stopedUser = new StopedUser()
            {
                ToUserDisplayName = string.Empty
            };

            return(stopedUser);
        }
        /// <summary>
        /// 把用户加入黑名单
        /// </summary>
        /// <param name="stopedUser">黑名单</param>
        public bool CreateStopedUser(StopedUser stopedUser)
        {
            FollowService followService = new FollowService();
            followService.CancelFollow(stopedUser.UserId, stopedUser.ToUserId);
            followService.CancelFollow(stopedUser.ToUserId, stopedUser.UserId);

            bool isCreat = stopedUserRepository.CreateStopedUser(stopedUser);
            EventBus<StopedUser>.Instance().OnAfter(stopedUser, new CommonEventArgs(EventOperationType.Instance().Create()));
            return isCreat;
        }
Exemple #3
0
        /// <summary>
        /// 把用户从黑名单中删除
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="toUserId">被加入黑名单的UserId</param>
        public void DeleteStopedUser(long userId, long toUserId)
        {
            Dictionary <long, StopedUser> stopedUsers = GetStopedUsers(userId);

            if (!stopedUsers.ContainsKey(toUserId))
            {
                return;
            }
            StopedUser stopedUser = stopedUsers[toUserId];

            stopedUserRepository.DeleteStopedUser(stopedUser);
            EventBus <StopedUser> .Instance().OnAfter(stopedUser, new CommonEventArgs(EventOperationType.Instance().Delete()));
        }
Exemple #4
0
        /// <summary>
        /// 把用户加入黑名单
        /// </summary>
        /// <param name="stopedUser">黑名单</param>
        public bool CreateStopedUser(StopedUser stopedUser)
        {
            FollowService followService = new FollowService();

            followService.CancelFollow(stopedUser.UserId, stopedUser.ToUserId);
            followService.CancelFollow(stopedUser.ToUserId, stopedUser.UserId);

            bool isCreat = stopedUserRepository.CreateStopedUser(stopedUser);

            EventBus <StopedUser> .Instance().OnAfter(stopedUser, new CommonEventArgs(EventOperationType.Instance().Create()));

            return(isCreat);
        }
        public ActionResult CreateStopedUser(string spaceKey, long stopedUserId)
        {
            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            IUser user = userService.GetUser(stopedUserId);
            if (user != null)
            {
                StopedUser stopedUser = new StopedUser
                {
                    ToUserDisplayName = user.DisplayName,
                    ToUserId = user.UserId,
                    UserId = userId
                };
                privacyService.CreateStopedUser(stopedUser);
            }
            return new EmptyResult();
        }
 public ActionResult Blacklist(string spaceKey, string blacklistId)
 {
     string[] userIds = new string[0];
     if (!string.IsNullOrEmpty(blacklistId))
         userIds = blacklistId.Split(new char[] { ',', ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
     int addCount = 0;
     long spaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);
     if (userIds.Length <= privacySettingsManager.Get().StopUserMaxCount)
     {
         foreach (var userId in userIds)
         {
             long Id = -1;
             if (long.TryParse(userId, out Id))
             {
                 if (privacyService.IsStopedUser(spaceUserId, Id))
                     continue;
                 IUser user = userService.GetUser(Id);
                 if (user == null)
                     continue;
                 StopedUser stopedUser = new StopedUser
                 {
                     ToUserDisplayName = user.DisplayName,
                     ToUserId = Id,
                     UserId = spaceUserId
                 };
                 if (privacyService.CreateStopedUser(stopedUser))
                     addCount++;
             }
         }
     }
     if (addCount > 0)
         TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功的把{0}人加入黑名单", addCount));
     else
         TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有把任何人加入黑名单");
     return Redirect(SiteUrls.Instance().Blacklist(spaceKey));
 }
Exemple #7
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static StopedUser New()
        {
            StopedUser stopedUser = new StopedUser()
            {
                ToUserDisplayName = string.Empty

            };
            return stopedUser;
        }