示例#1
0
        public async Task <PostEntityModel> AddPost(PostEntityModel post)
        {
            string url = _postsUrlBuilder.Build();

            var request = _postRequestBuilder
                          .WithPostData(post)
                          .Build();

            var response = await _httpClient.PostAsync(url, new StringContent(request));

            response.EnsureSuccessStatusCode();

            return(await response.Content.ReadFromJsonAsync <PostEntityModel>());
        }
示例#2
0
 public PostRequestBuilder WithPostData(PostEntityModel post)
 {
     _post = post;
     return(this);
 }