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

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

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

            return(LocationChanged(RewriteMapsHelper.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(RewriteMapsHelper.SectionToJsonModel(site, rewriteId.Path));
        }
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            var rewriteMapsId = new RewriteId(id);

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

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

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

            RewriteMapsHelper.UpdateSection(model, site, rewriteMapsId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(RewriteMapsHelper.SectionToJsonModel(site, rewriteMapsId.Path));
        }