コード例 #1
0
        public object Post([FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            RewriteId parentId = RewriteHelper.GetRewriteIdFromBody(model);

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

            string configPath            = ManagementUnit.ResolveConfigScope(model);
            OutboundRulesSection section = OutboundRulesHelper.GetSection(site, parentId.Path, configPath);

            PreCondition precondition = OutboundRulesHelper.CreatePreCondition(model, section);

            OutboundRulesHelper.AddPreCondition(precondition, section);

            ManagementUnit.Current.Commit();

            dynamic pc = OutboundRulesHelper.PreConditionToJsonModel(precondition, site, parentId.Path, Context.Request.GetFields(), true);

            return(Created(OutboundRulesHelper.GetRuleLocation(pc.id), pc));
        }