コード例 #1
0
        public async Task UnfollowUser(User user, HttpClient client)
        {
            if (!Logged)
            {
                return;
            }

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);

            if (Following.Any(e => e.Id == user.Id))
            {
                var response = await client.DeleteAsync($"api/users/{user.Id}/unfollow");

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Following.Remove(user);
                    FollowingCount--;
                }
            }
        }
コード例 #2
0
        public bool UnFollow(ProfileAggregate otherAggregate)
        {
            if (otherAggregate == default)
            {
                throw new ArgumentException("The user cannot be null");
            }
            if (otherAggregate.Id == Guid.Empty)
            {
                throw new ArgumentException("userid cannot be empty");
            }
            Follower follow = Following.Find(foll => foll.FollowerId == Id && foll.FollowingId == otherAggregate.Id);

            if (follow == default)
            {
                return(false);
            }
            otherAggregate.RemoveFollower(follow);
            Following.Remove(follow);
            return(true);
        }
コード例 #3
0
 internal void Unfollow(ApplicationUser user)
 {
     Following.Remove(user);
     user.Followers.Remove(this);
 }