// GET: api/PostApi/5 public PostPoco Get(int id) { var question = db.Questions.Single(q => q.Id == id); PostPoco poco = new PostPoco(question); return(poco); }
private async Task <PostModel> ConvertPostPocoToPostModel(PostPoco postPoco) { var model = PostModel.FromPoco(postPoco); var userPoco = await this.UserService.GetUserById(postPoco.UserId); model.Author = new PostUserModel { UserId = userPoco.UserId, Name = userPoco.Name }; var tagsPoco = await this.GetPostTags(postPoco.PostId); model.Tags = tagsPoco.Select(TagModel.FromPoco).ToArray(); model.Comments = await this.CommentService.GetCommentsWithPostId(postPoco.PostId); return(model); }
public static PostModel FromPoco(PostPoco poco) => new()