Ejemplo n.º 1
0
        public async Task <ActionResult <PostDTO> > savePosts(PostDTO post)
        {
            if (post == null)
            {
                return(BadRequest());
            }

            if (string.IsNullOrEmpty(post.PostDescription))
            {
                return(Problem(statusCode: 422, title: "Invalid data, PostDescription property cannot be empty!"));
            }

            if (string.IsNullOrEmpty(post.State.ToString()))
            {
                return(Problem(statusCode: 422, title: "Invalid data, State property cannot be empty!"));
            }

            if (string.IsNullOrEmpty(post.AuthorName.ToString()))
            {
                return(Problem(statusCode: 422, title: "Invalid data, AuthorName property cannot be empty!"));
            }

            var response = await _postsDomain.savePost(post);

            return(Ok(response));
        }