Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteComment(int id, int discussionId)
        {
            if (!PermissionsValidator.HasPermission(
                    this.commentService.GetCreatorId(id),
                    this.userManager.GetUserId(this.User),
                    this.User.IsInRole(AdministratorRole)))
            {
                return(this.Unauthorized());
            }

            await this.commentService.DeleteAsync(id);

            if (discussionId == default)
            {
                return(this.RedirectToAction(nameof(this.All)));
            }

            return(this.RedirectToAction(nameof(this.Discussion), new { id = discussionId }));
        }
Ejemplo n.º 2
0
 private bool HasPermission(int dataId)
 => PermissionsValidator.HasPermission(
     this.adsService.GetCreatorId(dataId),
     this.userManager.GetUserId(this.User),
     this.User.IsInRole(AdministratorRole));