public GetPostByIdViewModel GetPostById(GetPostByIdInputModel data, string virtualPath) { var posts = _postRepository.GetById(data.id, data.projectKey); var postsVM = new GetPostByIdViewModel( posts.Id, posts.CreatedAt, posts.ProjectKey, posts.Title, posts.Content); return(postsVM); }
public IActionResult GetPostageById([FromRoute] int id, [FromQuery] GetPostByIdInputModel data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { data.id = id; var result = _service.GetPostById(data, GetVirtualPath()); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }