示例#1
0
        public IActionResult save(string userID, string permissionsJson, string rolesJson)
        {
            var permissions = JsonConvert.DeserializeObject <List <Permission> >(permissionsJson);
            var roles       = JsonConvert.DeserializeObject <List <Role> >(rolesJson);
            int i           = new DataManager(userID).SaveUser(userID, permissions, roles);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }
示例#2
0
        public IActionResult AddKey(string name, string userId = null)
        {
            if (string.IsNullOrEmpty(userId))
            {
                userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            }
            int i = new DataManager(userId).AddKey(name, userId);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }
示例#3
0
        public IActionResult AddRole(string values)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            var d = JsonConvert.DeserializeObject <RoleResult>(values);

            int i = new DataManager(userId).AddRole(d.Name);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }
示例#4
0
        public IActionResult deleteCat(long autokey, string userId = null)
        {
            if (string.IsNullOrEmpty(userId))
            {
                userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            }

            int i = new DataManager(userId).DeleteCategory(autokey);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }
示例#5
0
        public IActionResult saveRole(string roleID, string permissionsJson, string userId = null)
        {
            if (string.IsNullOrEmpty(userId))
            {
                userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            }

            var permissions = JsonConvert.DeserializeObject <List <Permission> >(permissionsJson);
            int i           = new DataManager(userId).SaveRole(roleID, permissions);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }
示例#6
0
        public IActionResult UpdateRole(int key, string values, string userId = null)
        {
            // Update
            if (string.IsNullOrEmpty(userId))
            {
                userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            }


            var d = JsonConvert.DeserializeObject <RoleResult>(values);

            int i = new DataManager(userId).UpdateRole(key, d.Name);

            AuthorizationController.Result result = new AuthorizationController.Result();
            result.StatusName = ((ErrorCodes)i).ToString();
            result.StatusCode = i;

            return(new JsonResult(result));
        }