Esempio n. 1
0
        public async Task <IActionResult> GetPosts()
        {
            var posts    = _IPostService.GetPosts();
            var PostsDto = _mapper.Map <IEnumerable <PostDto> >(posts);
            var response = new ApiGenericResponse <IEnumerable <PostDto> >(PostsDto);

            return(Ok(response));
        }
Esempio n. 2
0
        public async Task <IActionResult> CreatePost(PostDto postDto)
        {
            var posts = _mapper.Map <Post>(postDto);
            await _IPostService.CreatePost(posts);

            postDto = _mapper.Map <PostDto>(posts);
            var response = new ApiGenericResponse <PostDto>(postDto);

            return(Ok(response));
        }
 private async Task PerformPostFromExampleAsync(ExampleRequest request)
 {
     try
     {
         apiResponse = await exampleRestApiClient.PostResultFromExampleAsync(request);
     }
     catch (ApiException ex)
     {
         apiException = ex;
     }
 }
Esempio n. 4
0
        public async Task <IActionResult> UpdatePost(int id, PostDto postDto)
        {
            var post = _mapper.Map <Post>(postDto);

            post.Id = id;
            if (id == 0)
            {
                throw new Exception("IT CANT BE NULL");
            }
            else
            {
                await _IPostService.UpadatePost(post);

                postDto = _mapper.Map <PostDto>(post);
                var response = new ApiGenericResponse <PostDto>(postDto);


                return(Ok(response));
            }
        }