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--; } } }
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); }
internal void Unfollow(ApplicationUser user) { Following.Remove(user); user.Followers.Remove(this); }