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); }
public object Get(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()); } TagsElement tag = OutboundRulesHelper.GetSection(site, customTagsId.Path).Tags.FirstOrDefault(tags => tags.Name.Equals(customTagsId.Name, StringComparison.OrdinalIgnoreCase)); if (tag == null) { return(NotFound()); } return(OutboundRulesHelper.TagsToJsonModel(tag, site, customTagsId.Path, Context.Request.GetFields())); }
public void Delete(string id) { TagsElement tags = null; var tagsId = new CustomTagsId(id); Site site = tagsId.SiteId == null ? null : SiteHelper.GetSite(tagsId.SiteId.Value); if (tagsId.SiteId == null || site != null) { tags = OutboundRulesHelper.GetSection(site, tagsId.Path).Tags.FirstOrDefault(t => t.Name.Equals(tagsId.Name, StringComparison.OrdinalIgnoreCase)); } if (tags != null) { var section = OutboundRulesHelper.GetSection(site, tagsId.Path, ManagementUnit.ResolveConfigScope()); OutboundRulesHelper.DeleteCustomTags(tags, section); ManagementUnit.Current.Commit(); } Context.Response.StatusCode = (int)HttpStatusCode.NoContent; }