public static async Task Delete(int id, Account account) { var comment = Get(id); var conditionOfAdmin = account.Access == EnumAccess.Administrator; var conditionOfMod = account.Access == EnumAccess.Moderator && (EnumAccess.BannedUser | EnumAccess.NormalUser).HasFlag(comment.Owner.Access); var conditionOfNormal = comment.IsOwner(account); if (!(conditionOfAdmin || conditionOfMod || conditionOfNormal)) { throw new Error403Forbidden <Comment>("Bạn không có quyền xóa bình luận này"); } await CommentDataAccess.Delete(comment); }
public void Delete(int commentId) { _commentDal.Delete(commentId); }