示例#1
0
        public async Task <ResponseFromApi <int> > UpdatePost(PostDetailBlazorVM postDetailViewModel)
        {
            try
            {
                UpdatePostCommand updatePostCommand = _mapper.Map <UpdatePostCommand>(postDetailViewModel);
                await _client.UpdatePostAsync(updatePostCommand);

                return(new ResponseFromApi <int>()
                {
                    Success = true
                });
            }
            catch (ApiException ex)
            {
                return(ex.ConvertApiExceptions());
            }
        }
示例#2
0
        public async Task <ResponseFromApi <int> > CreatePost(PostDetailBlazorVM postDetailViewModel)
        {
            try
            {
                CreatedPostCommand createPostCommand =
                    _mapper.Map <CreatedPostCommand>(postDetailViewModel);

                var newId = await _client.AddPostAsync(createPostCommand);

                return(new ResponseFromApi <int>()
                {
                    Data = newId, Success = true
                });
            }
            catch (ApiException ex)
            {
                return(ex.ConvertApiExceptions());
            }
        }