public IActionResult Index(string currentUrl)
        {
            string   userId   = "1"; // Get UserID from IIdentity
            ModuleUi moduleUI = _context.ModuleUi.FirstOrDefault(x => x.Url == currentUrl);

            if (moduleUI.IsOpen)
            {
                return(Json(new { IsOpen = true, data = "", IsPermitted = true }));
            }

            UserModuleUi userModuleUI = _context.UserModuleUi.FirstOrDefault(x => x.ModuleUiid == moduleUI.Id);

            if (userModuleUI == null)
            {
                return(Json(new { IsOpen = true, data = "", IsPermitted = false }));
            }

            if (userModuleUI.HasFullAccess)
            {
                return(Json(new { IsOpen = true, data = "", IsPermitted = true }));
            }

            List <UserModuleUicontrolsPermissions> permittedItems = _context.UserModuleUicontrolsPermissions.Where(x => x.ModuleUiid == moduleUI.Id && x.UserId == userId).ToList();

            return(Json(new { IsOpen = moduleUI.IsOpen, data = permittedItems, IsPermitted = true }));
        }
    public Task HandleAsync(AuthorizationHandlerContext context)
    {
        if (context.User.Identity.IsAuthenticated)
        {
            List <IAuthorizationRequirement> pendingRequirements = context.PendingRequirements.ToList();
            HttpContext  httpContext  = _contextAccessor.HttpContext;
            PathString   path         = httpContext.Request.Path;
            UserModuleUi userModuleUI = _context.UserModuleUi.Include(x => x.ModuleUi).FirstOrDefault(x => x.ModuleUi.Url == path);
            if (userModuleUI != null)
            {
                if (userModuleUI.IsOpen || userModuleUI.HasFullAccess)
                {
                    pendingRequirements.ForEach(x => context.Succeed(x));
                }
                UserModuleUicontrolsPermissions userControlPermission = _context.UserModuleUicontrolsPermissions.Include(x => x.ModuleUicontrols).FirstOrDefault(c => c.ModuleUicontrols.ControlName == GetControlName(path));
                if (userControlPermission != null)
                {
                    if (userControlPermission.IsPermitted == true)
                    {
                        pendingRequirements.ForEach(x => context.Succeed(x));
                    }
                }
            }
        }

        return(Task.CompletedTask);
    }