Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. [Authorize]
  2.         [Route("/Blog/Post/{id}")]
  3.         public async Task<IActionResult> Index(string id)
  4.         {
  5.             var isBlocked = await this.userValidator.IsBlocked(this.HttpContext);
  6.             if (isBlocked == true)
  7.             {
  8.                 this.TempData["Error"] = ErrorMessages.YouAreBlock;
  9.                 return this.RedirectToAction("Index", "Blog");
  10.             }
  11.  
  12.             var isInRole = await this.userValidator.IsInBlogRole(this.HttpContext);
  13.             if (!isInRole)
  14.             {
  15.                 this.TempData["Error"] = string.Format(ErrorMessages.NotInBlogRoles, Roles.Contributor);
  16.                 return this.RedirectToAction("Index", "Blog");
  17.             }
  18.  
  19.             var isApproved = await this.userValidator.IsPostApproved(id, this.HttpContext);
  20.             if (!isApproved)
  21.             {
  22.                 this.TempData["Error"] = ErrorMessages.NotApprovedBlogPost;
  23.                 return this.RedirectToAction("Index", "Blog");
  24.             }
  25.  
  26.             PostViewModel model = await this.postService.ExtractCurrentPost(id, this.HttpContext);
  27.             return this.View(model);
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement