コード例 #1
0
        public object Patch([FromBody] dynamic model, string id)
        {
            var customTagsId = new CustomTagsId(id);

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

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

            OutboundRulesSection section = OutboundRulesHelper.GetSection(site, customTagsId.Path);
            TagsElement          tags    = section.Tags.FirstOrDefault(t => t.Name.Equals(customTagsId.Name, StringComparison.OrdinalIgnoreCase));

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

            OutboundRulesHelper.UpdateCustomTags(model, tags, section);

            ManagementUnit.Current.Commit();

            dynamic updatedCustomTags = OutboundRulesHelper.TagsToJsonModel(tags, site, customTagsId.Path, Context.Request.GetFields(), true);

            if (updatedCustomTags.id != id)
            {
                return(LocationChanged(OutboundRulesHelper.GetCustomTagsLocation(updatedCustomTags.id), updatedCustomTags));
            }

            return(updatedCustomTags);
        }