Exemplo n.º 1
0
        protected override async Task ActionAsync()
        {
            if (string.IsNullOrEmpty(Input.UserId))
            {
                throw new NotAuthentifiedException("You are not authorized to process this action.");
            }

            if (string.IsNullOrEmpty(Input.Data.ModuleId))
            {
                throw new ArgumentException("ModuleId should not be empty");
            }

            if (string.IsNullOrEmpty(Input.Data.CommentId))
            {
                throw new ArgumentException("CommentId should not be empty");
            }

            var user = await _userService.FindApplicationUserByIdAsync(Input.UserId);

            var commentDbModel = await _commentService.GetCommentsAsync(Input.Data.ModuleId);

            var comment = commentDbModel.Comments.First(p => p.Id == Input.Data.CommentId);

            if (comment.UserId != user.Id)
            {
                Result.ValidationResult.AddError("401", "You are not authorized to process this action.");
            }

            await _commentService.DeleteCommentAsync(Input.Data.SiteId, Input.Data.ModuleId, Input.Data.CommentId);

            var result =
                await
                AddCommentCommand.GetCommentsResult(Input.Data.ModuleId, _commentService, _userService, Input.UserId);

            Result.Data = result;
        }
Exemplo n.º 2
0
 protected override async Task ActionAsync()
 {
     Result.Data =
         await AddCommentCommand.GetCommentsResult(Input.ModuleId, _commentService, _userService, string.Empty);
 }