コード例 #1
0
        public async Task Unfollow(Follower follower)
        {
            await _followerRepository.DeleteFollower(follower);

            if (!_inMemoryStorage.UserFollowers.TryGetValue(follower.FollowedUserId, out List <int> followers))
            {
                followers = new List <int>();
                _inMemoryStorage.UserFollowers[follower.FollowedUserId] = followers;
            }

            followers.Remove(follower.FollowingUserId);

            if (followers.Count < Constants.CELEBRITY_FOLLOWERS_MIN_AMOUNT)
            {
                _inMemoryStorage.Celebrities.Remove(follower.FollowedUserId);
            }

            _feedManager.RemoveFromFeed(follower.FollowingUserId, follower.FollowedUserId);
        }