Пример #1
0
        public ServiceResult AddPermissionsToRole(string roleUUID)
        {
            string root     = EnvironmentEx.AppDataFolder;
            var    provider = new MultipartFormDataStreamProvider(root);

            try
            {
                Task <string> content = ActionContext.Request.Content.ReadAsStringAsync();
                if (content == null)
                {
                    return(ServiceResponse.Error("No permissions were sent."));
                }

                string body = content.Result;

                if (string.IsNullOrEmpty(body))
                {
                    return(ServiceResponse.Error("No permissions were sent."));
                }

                List <Permission> perms = JsonConvert.DeserializeObject <List <Permission> >(body);

                RoleManager roleManager = new RoleManager(Globals.DBConnectionKey, this.GetUser(Request.Headers?.Authorization?.Parameter));
                return(roleManager.AddPermisssionsToRole(roleUUID, perms, CurrentUser));
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            return(ServiceResponse.OK());
        }
Пример #2
0
        public ServiceResult AddPermissionsToRole(string roleUUID)
        {
            try
            {
                Task <string> content = Request.Content.ReadAsStringAsync();
                if (content == null)
                {
                    return(ServiceResponse.Error("No permissions were sent."));
                }

                string body = content.Result;

                if (string.IsNullOrEmpty(body))
                {
                    return(ServiceResponse.Error("No permissions were sent."));
                }

                List <Permission> perms = JsonConvert.DeserializeObject <List <Permission> >(body);

                RoleManager roleManager = new RoleManager(Globals.DBConnectionKey, this.GetUser(this.GetAuthToken(Request)));
                return(roleManager.AddPermisssionsToRole(roleUUID, perms, CurrentUser));
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            return(ServiceResponse.OK());
        }