Пример #1
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            AuthorizationId authId = new AuthorizationId(id);

            Site site = authId.SiteId == null ? null : SiteHelper.GetSite(authId.SiteId.Value);

            if (authId.SiteId != null && site == null)
            {
                return(NotFound());
            }

            // Check for config_scope
            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);
            var    section    = AuthorizationHelper.GetSection(site, authId.Path, configPath);

            AuthorizationHelper.UpdateFeatureSettings(model, section);

            ManagementUnit.Current.Commit();

            dynamic authorization = AuthorizationHelper.ToJsonModel(site, authId.Path);

            if (authorization.id != id)
            {
                return(LocationChanged(AuthorizationHelper.GetLocation(authorization.id), authorization));
            }

            return(authorization);
        }
Пример #2
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            return(AuthorizationHelper.ToJsonModel(site, path));
        }
Пример #3
0
        public object Get(string id)
        {
            AuthorizationId authId = new AuthorizationId(id);

            Site site = authId.SiteId == null ? null : SiteHelper.GetSite(authId.SiteId.Value);

            return(AuthorizationHelper.ToJsonModel(site, authId.Path));
        }
Пример #4
0
        public async Task <object> Post()
        {
            if (AuthorizationHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(AuthorizationHelper.FEATURE_NAME);
            }

            await AuthorizationHelper.SetFeatureEnabled(true);

            dynamic auth = AuthorizationHelper.ToJsonModel(null, null);

            return(Created(AuthorizationHelper.GetLocation(auth.id), auth));
        }