Beispiel #1
0
 public PostSlugViewModelWrapper(PostSlug postModel)
 {
     PostModel           = postModel;
     NewCommentViewModel = new NewCommentViewModel {
         PostId = PostModel.Id
     };
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
    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;
 }