Example #1
0
        public async Task <IActionResult> Review([FromRoute] string slug)
        {
            var post = await _postService.GetPost(slug);

            if (post == null)
            {
                return(NotFound());
            }

            return(View(PostEditViewModel.FromModel(post)));
        }
Example #2
0
        public async Task <IActionResult> Detail(string slug)
        {
            var post = await _postService.GetPost(slug);

            if (post == null)
            {
                return(NotFound());
            }

            // TODO: Check post's status against user role i.e.: Unauthenticated should not see Drafts or Pending posts

            return(View(
                       PostDetailViewModel.FromModel(post)));
        }
        public async Task <IActionResult> Approve([FromRoute] string slug)
        {
            var post = await _postService.GetPost(slug);

            if (post?.Status != Services.PostStatus.Pending)
            {
                return(NotFound());
            }

            post.Status       = Services.PostStatus.Published;
            post.ApprovalDate = DateTime.Now;

            var result = await _postService.SavePost(post);

            if (!result.Success)
            {
                return(this.UnprocessableEntity(result.Error));
            }

            return(Ok());
        }