private async Task <OperationResult <IEnumerable <AuthorViewModel> > > RequestGetAuthorsAsync(ClaimManager model) { HttpClient client = _retrieveToIdentityServer.RetrieveToIdentityServer(_httpClientFactory, model.AccessToken); HttpResponseMessage response = (await client.GetAsync("https://localhost:5001/api/author/getauthors/")).EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); OperationResult <IEnumerable <AuthorViewModel> > operation = JsonConvert.DeserializeObject <OperationResult <IEnumerable <AuthorViewModel> > >(responseBody); return(operation); }
private async Task RequestCreateArticleAsync(ClaimManager model, ArticleViewModel article) { HttpClient client = _retrieveToIdentityServer.RetrieveToIdentityServer(_httpClientFactory, model.AccessToken); string json = JsonConvert.SerializeObject(article); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = (await client.PostAsync("https://localhost:5001/api/article/createarticle/", content)).EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); //OperationResult<ArticleViewModel> operation = JsonConvert.DeserializeObject<OperationResult<ArticleViewModel>>(responseBody); //use on the page to show the article to its creator }