Esempio n. 1
0
        public IActionResult CheckPermission([FromBody] AdminCheckPermissionView checkView)
        {
            IActionResult response   = null;
            UserModels    userModels = new UserModels();

            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;
            var userLogin = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value;

            var action = userModels.GetActionByActionName(checkView.TypeAct);

            string typeAct = action != null?action.Id.ToString() : string.Empty;

            ////check permission update
            if (UserModels.CheckPermission(userLogin, checkView.Path, typeAct, checkView.Type))
            {
                response = Json(new { code = Constant.PermissionAccessCode, message = Constant.MessagePermissionAccess });
            }
            else
            {
                response = Json(new { code = Constant.PermissionDeniedCode, message = Constant.MessagePermissionDenied });
            }

            return(response);
        }
        public IActionResult ListUserPage(string type, string search, int?parentId, int?pageIndex, int?pageSize)
        {
            IActionResult response   = null;
            BaseClass     baseClass  = new BaseClass();
            UserModels    userModels = new UserModels();
            RoleModels    roleModels = new RoleModels();
            User          cuser      = new User();

            var mess         = string.Empty;
            var listPageView = new AdminListPageView();
            var isOk         = true;

            string lang = LanguageModels.ActiveLanguage().LangCultureName;

            type = type ?? string.Empty;

            if (parentId == null)
            {
                parentId = -1; // get all
            }

            var action = userModels.GetActionByActionName(CommonGlobal.View);

            string typeAct = action != null?action.Id.ToString() : string.Empty;

            if (type == string.Empty)
            {
                isOk     = false;
                response = Json(new { code = Constant.NotExist, message = Constant.MessageNotExist });
            }

            if (!isOk)
            {
                return(response);
            }

            listPageView.ListUserPage = userModels.AdminGetAllPageFullTree(type, lang, search, (int)parentId, (int)pageIndex, (int)pageSize, out int totalRecord);
            listPageView.CateType     = roleModels.GetRoleByRole(type);
            listPageView.PageIndex    = (int)pageIndex;
            listPageView.PageSize     = (int)pageSize;
            listPageView.TotalPage    = totalRecord > 0 ? (int)System.Math.Ceiling((double)totalRecord / (double)pageSize) : 0;
            listPageView.TotalRecord  = totalRecord;

            response = Json(listPageView);

            return(response);
        }
        public IActionResult ListUserPageActionByPageId(string type, int pageId)
        {
            IActionResult response   = null;
            BaseClass     baseClass  = new BaseClass();
            UserModels    userModels = new UserModels();
            RoleModels    roleModels = new RoleModels();
            User          cuser      = new User();

            var mess = string.Empty;
            var isOk = true;

            string lang = LanguageModels.ActiveLanguage().LangCultureName;

            type = type ?? "Admin";

            var action = userModels.GetActionByActionName(CommonGlobal.View);

            string typeAct = action != null?action.Id.ToString() : string.Empty;

            if (type == string.Empty)
            {
                isOk     = false;
                response = Json(new { code = Constant.NotExist, message = Constant.MessageNotExist });
            }

            if (!isOk)
            {
                return(response);
            }

            List <UserPageAction> listAllPageAction = userModels.AdminGetAllPageAction(type, lang, pageId);

            response = Json(listAllPageAction);

            return(response);
        }