public object Get()
        {
            RewriteHelper.ResolveRewrite(Context, out Site site, out string path);

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

            dynamic d = GlobalRulesHelper.SectionToJsonModel(site, path);

            return(LocationChanged(GlobalRulesHelper.GetSectionLocation(d.id), d));
        }
        public object Get(string id)
        {
            var rewriteId = new RewriteId(id);

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

            if (rewriteId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            return(GlobalRulesHelper.SectionToJsonModel(site, rewriteId.Path));
        }
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            RewriteId globalRulesId = new RewriteId(id);

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

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

            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);

            GlobalRulesHelper.UpdateSection(model, site, globalRulesId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(GlobalRulesHelper.SectionToJsonModel(site, globalRulesId.Path));
        }