Exemple #1
0
        /// <summary>
        /// “关注”指定的目标用户(异步)
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="targetUserId">被关注的目标用户编号</param>
        public static async void FollowedTargetUser(int userId, int targetUserId)
        {
            await Task.Run(() =>
            {
                UserFollowed uFollowed = new UserFollowed {
                    UserId = userId, FollowedUserId = targetUserId, CreateDate = DateTime.Now
                };
                bool result = SocialData.ChangedFollowedWithTargetUser(uFollowed, 1);
                if (result)
                {
                    SocialConfig config = SocialConfigs.GetSocialConfigCache();

                    if (config.BeFollowedExpChanged != 0)
                    {
                        UserBiz.UpdateUserExp(targetUserId, config.BeFollowedExpChanged, "被关注");
                    }

                    if (config.BeFollowedCoinChanged != 0)
                    {
                        UserBiz.UpdateUserCoin(targetUserId, config.BeFollowedCoinChanged, "被关注");
                    }

                    UserBiz.SetUserCacheInfo(userId);
                    UserBiz.SetUserCacheInfo(targetUserId);

                    //发送系统消息给被关注对象,提醒该用户被“关注”
                    //Todo....
                }
            });
        }
Exemple #2
0
 /// <summary>
 /// 取消“关注”指定的目标用户(异步)
 /// </summary>
 /// <param name="userId">用户编号</param>
 /// <param name="targetUserId">被关注的目标用户编号</param>
 public static async void RemoveFollowedByTargetUser(int userId, int targetUserId)
 {
     await Task.Run(() =>
     {
         UserFollowed uFollowed = new UserFollowed {
             UserId = userId, FollowedUserId = targetUserId, CreateDate = DateTime.Now
         };
         bool result = SocialData.ChangedFollowedWithTargetUser(uFollowed, 0);
         if (result)
         {
             UserBiz.SetUserCacheInfo(userId);
             UserBiz.SetUserCacheInfo(targetUserId);
         }
     });
 }