Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        private async Task <string> UploadPhoto(IFormFile photo)
        {
            var formData = await photo.ConvertFormFileToMultipartForm();

            return(await _http.Post("filestorage", "/SaveFile", formData));
        }