Beispiel #1
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            RuleId ruleId = new RuleId(id);

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

            Rule rule = AuthorizationHelper.GetRule(site, ruleId.Path, ruleId.Users, ruleId.Roles, ruleId.Verbs);

            if (rule == null)
            {
                return(NotFound());
            }

            rule = AuthorizationHelper.UpdateRule(rule, model);

            ManagementUnit.Current.Commit();

            dynamic r = AuthorizationHelper.RuleToJsonModel(rule, site, ruleId.Path);

            if (r.id != id)
            {
                return(LocationChanged(AuthorizationHelper.GetRuleLocation(r.id), r));
            }
            ;

            return(r);
        }