public ActionResult <Post> AddPost(PostDTO post) { var owner = _userRepository.GetById(post.OwnerId); if (owner == null) { return(NotFound()); } Post newpost = new Post(post.Title, post.Body, owner); _postRepository.Addpost(newpost); _postRepository.SaveChanges(); return(CreatedAtAction(nameof(GetById), new { id = newpost.PostId }, newpost)); }