public async Task ChangeFriendListAsync(ReqFriendStr obj) { var js = JsonConvert.SerializeObject(obj); HttpContent cont = new StringContent(js, Encoding.UTF8, "application/json"); var response = await _apiService.callPutAPI("http://localhost:5012/friends", cont); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); } }
public async Task jsAddFriend(string id) { var obj = new ReqFriendStr { Id = User.Identity.Name, //Method = "Add", UserId = id }; var myProfile = _profileService.Get(User.Identity.Name); if (myProfile.Friends?.Where(x => x == id).Count() > 0) { obj.Method = "Del"; } else { obj.Method = "Add"; } await ChangeFriendListAsync(obj); }