コード例 #1
0
        public object Get()
        {
            RewriteHelper.ResolveRewrite(Context, out Site site, out string path);

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

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

            return(LocationChanged(OutboundRulesHelper.GetSectionLocation(d.id), d));
        }
コード例 #2
0
        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(OutboundRulesHelper.SectionToJsonModel(site, rewriteId.Path));
        }
コード例 #3
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            var outboundRulesId = new RewriteId(id);

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

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

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

            OutboundRulesHelper.UpdateSection(model, site, outboundRulesId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(OutboundRulesHelper.SectionToJsonModel(site, outboundRulesId.Path));
        }