public PostSlugViewModelWrapper(PostSlug postModel) { PostModel = postModel; NewCommentViewModel = new NewCommentViewModel { PostId = PostModel.Id }; }
public async Task <IActionResult> Slug(int year, int month, int day, string slug) { if (year > DateTime.UtcNow.Year || string.IsNullOrWhiteSpace(slug)) { return(NotFound()); } var slugInfo = new PostSlug(year, month, day, slug); var post = await _postService.GetAsync(slugInfo); if (post is null) { return(NotFound()); } ViewBag.TitlePrefix = $"{post.Title}"; return(View(post)); }
public async Task <IActionResult> OnGetAsync(int year, int month, int day, string slug) { if (year > DateTime.UtcNow.Year || string.IsNullOrWhiteSpace(slug)) { return(NotFound()); } var slugInfo = new PostSlug(year, month, day, slug); var post = await _mediator.Send(new GetPostBySlugQuery(slugInfo)); if (post is null) { return(NotFound()); } ViewData["TitlePrefix"] = $"{post.Title}"; Post = post; return(Page()); }
public GetPostBySlugQuery(PostSlug slug) { Slug = slug; }