public async Task <UserProfileInputModel> GetProfileToEditByIdAsync(string memberId) { var result = await _httpClient.GetAsync($"api/profile/{memberId}/edit"); if (result.IsSuccessStatusCode) { var userInputmodel = await result.Content.ReadAsAsync <UserProfileInputModel>(); return(userInputmodel); } return(null); }
public async Task <AppHttpResponseMessageWrapper> GetUserNameByEmailAsync(string userEmail) { var result = await _httpClient.GetAsync($"api/users/{userEmail}/username"); var wrapperResult = new AppHttpResponseMessageWrapper(result); if (result.IsSuccessStatusCode) { var userName = await result.Content.ReadAsStringAsync(); wrapperResult.UserName = RegexHelper.CleanHttpResponceString(userName); } wrapperResult.ErrorMessage = await result.Content.ReadAsStringAsync(); return(wrapperResult); }
protected override async Task OnInitializedAsync() { NewItem = new ItemCreateApiModel(); ApiCallResult <IList <ItemApiModel> > apiCallResult = await AppHttpClient.GetAsync <IList <ItemApiModel> >(ApiUrls.GetItemsList); Items = apiCallResult.IsSuccess ? apiCallResult.Value ! : throw new Exception("API call is not successful"); }
public async Task <List <User> > GetUsers() { List <User> _listUsers = new List <User>(); var response = await _client.GetAsync(_options.ApiUrl + "api/Users"); if (response.IsSuccessStatusCode) { var jsonUsers = await response.Content.ReadAsStringAsync(); _listUsers = JsonConvert.DeserializeObject <List <User> >(jsonUsers); if (_listUsers == null || _listUsers.Count == 0) { return(new List <User>()); } } return(_listUsers); }