public IActionResult Read(string slug) { if (string.IsNullOrWhiteSpace(slug)) { return(NotFound()); } var strSlug = slug.Trim().ToLower(); var post = PostRepository.GetPostBySlug(strSlug); if (null != post) { // get tags var tags = PostTagAssociationRepository.GetTagsByPost(post.Id); // get categories var cats = PostCategoryAssociationRepository.GetCatsByPost(post.Id); // get comments var cmts = CommentRepository.GetCommentsByPostId(post.Id); var viewModel = new PostReadViewModel() { Post = post, Tags = tags?.ToList() ?? new List <Tag>(), Categories = cats?.ToList() ?? new List <Category>(), Comments = cmts?.ToList() ?? new List <Comment>() }; return(View(viewModel)); } else { return(NotFound()); } }
public PostReadPage(Post post) { InitializeComponent(); BindingContext = new PostReadViewModel(post); }