Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Authorize]
- [Route("/Blog/Post/{id}")]
- public async Task<IActionResult> Index(string id)
- {
- var isBlocked = await this.userValidator.IsBlocked(this.HttpContext);
- if (isBlocked == true)
- {
- this.TempData["Error"] = ErrorMessages.YouAreBlock;
- return this.RedirectToAction("Index", "Blog");
- }
- var isInRole = await this.userValidator.IsInBlogRole(this.HttpContext);
- if (!isInRole)
- {
- this.TempData["Error"] = string.Format(ErrorMessages.NotInBlogRoles, Roles.Contributor);
- return this.RedirectToAction("Index", "Blog");
- }
- var isApproved = await this.userValidator.IsPostApproved(id, this.HttpContext);
- if (!isApproved)
- {
- this.TempData["Error"] = ErrorMessages.NotApprovedBlogPost;
- return this.RedirectToAction("Index", "Blog");
- }
- PostViewModel model = await this.postService.ExtractCurrentPost(id, this.HttpContext);
- return this.View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement