public object Patch(string id, [FromBody] dynamic model) { UrlId urlId = new UrlId(id); Site site = urlId.SiteId == null ? null : SiteHelper.GetSite(urlId.SiteId.Value); if (urlId.SiteId != null && site == null) { return(NotFound()); } UrlRule url = UrlsHelper.GetUrls(site, urlId.Path).FirstOrDefault(u => u.Url.Equals(urlId.Url, StringComparison.OrdinalIgnoreCase)); if (url == null) { return(NotFound()); } string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model); UrlsHelper.UpdateUrl(url, model, site, urlId.Path, configPath); ManagementUnit.Current.Commit(); dynamic urlModel = UrlsHelper.ToJsonModel(url, site, urlId.Path); if (urlModel.id != id) { return(LocationChanged(UrlsHelper.GetLocation(urlModel.id), urlModel)); } return(urlModel); }
public object Get(string id) { UrlId urlId = new UrlId(id); Site site = urlId.SiteId == null ? null : SiteHelper.GetSite(urlId.SiteId.Value); if (urlId.SiteId != null && site == null) { return(NotFound()); } UrlRule url = UrlsHelper.GetUrls(site, urlId.Path).FirstOrDefault(u => u.Url.Equals(urlId.Url, StringComparison.OrdinalIgnoreCase)); if (url == null) { return(NotFound()); } return(UrlsHelper.ToJsonModel(url, site, urlId.Path)); }
public object Post([FromBody] dynamic model) { if (model == null) { throw new ApiArgumentException("model"); } if (model.request_filtering == null) { throw new ApiArgumentException("request_filtering"); } if (!(model.request_filtering is JObject)) { throw new ApiArgumentException(String.Empty, "request_filtering"); } string reqUuid = DynamicHelper.Value(model.request_filtering.id); if (reqUuid == null) { throw new ApiArgumentException("request_filtering.id"); } // Get the feature id RequestFilteringId reqId = new RequestFilteringId(reqUuid); Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value); string configPath = ManagementUnit.ResolveConfigScope(model); RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath); UrlRule url = UrlsHelper.CreateUrl(model, section); UrlsHelper.AddUrl(url, section); ManagementUnit.Current.Commit(); // // Create response dynamic u = UrlsHelper.ToJsonModel(url, site, reqId.Path); return(Created(UrlsHelper.GetLocation(u.id), u)); }