public async Task Handle(AddPost notification, CancellationToken cancellationToken) { var postDto = new AddPostCommandDto { Description = notification.Description, ResourceName = notification.Photo != null ? await SaveFile(notification.Photo) : string.Empty }; var requestBody = JsonConvert.SerializeObject(postDto); var requestContent = new StringContent(requestBody, Encoding.UTF8, "application/json"); await _http.Post("posts", "/AddPost", requestContent); }
private async Task AddComment(AddComment notification) { var dto = new AddCommentDto { Text = notification.Text, PostOwnerUuid = notification.PostOwnerUuid, PostUuid = notification.PostUuid }; var content = new StringContent( JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"); await _http.Post("posts", "/AddComment", content); }
private async Task <IEnumerable <PostDto> > GetPosts(IEnumerable <string> myFriendsUuids, GetMainpagePosts request) { var dto = new GetMainpagePostsDto { LastPostFetched = request.LastPostFetched, Page = request.Page, MyFriendsUuids = myFriendsUuids }; var content = new StringContent( JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"); var result = await _http.Post("posts", "/GetMainpagePosts", content); return(JsonConvert.DeserializeObject <IEnumerable <PostDto> >(result)); }
private async Task <string> UploadPhoto(IFormFile photo) { var formData = await photo.ConvertFormFileToMultipartForm(); return(await _http.Post("filestorage", "/SaveFile", formData)); }