public void Delete(string id) { QueryStringId queryStringId = new QueryStringId(id); Site site = queryStringId.SiteId == null ? null : SiteHelper.GetSite(queryStringId.SiteId.Value); if (queryStringId.SiteId != null && site == null) { Context.Response.StatusCode = (int)HttpStatusCode.NoContent; return; } QueryStringRule queryString = QueryStringsHelper.GetQueryStrings(site, queryStringId.Path).FirstOrDefault(r => r.QueryString.ToString().Equals(queryStringId.QueryString)); if (queryString != null) { var section = RequestFilteringHelper.GetRequestFilteringSection(site, queryStringId.Path, ManagementUnit.ResolveConfigScope()); QueryStringsHelper.DeleteQueryString(queryString, section); ManagementUnit.Current.Commit(); } Context.Response.StatusCode = (int)HttpStatusCode.NoContent; return; }
public object Patch(string id, [FromBody] dynamic model) { QueryStringId queryStringId = new QueryStringId(id); Site site = queryStringId.SiteId == null ? null : SiteHelper.GetSite(queryStringId.SiteId.Value); if (queryStringId.SiteId != null && site == null) { return(new StatusCodeResult((int)HttpStatusCode.NotFound)); } QueryStringRule queryString = QueryStringsHelper.GetQueryStrings(site, queryStringId.Path).FirstOrDefault(s => s.QueryString.ToString().Equals(queryStringId.QueryString)); if (queryString == null) { return(NotFound()); } string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model); QueryStringsHelper.UpdateQueryString(queryString, model, site, queryStringId.Path, configPath); ManagementUnit.Current.Commit(); dynamic qs = QueryStringsHelper.ToJsonModel(queryString, site, queryStringId.Path); if (qs.id != id) { return(LocationChanged(QueryStringsHelper.GetLocation(qs.id), qs)); } return(qs); }
public static object ToJsonModelRef(QueryStringRule queryString, Site site, string path) { if (queryString == null) { return(null); } QueryStringId id = new QueryStringId(site?.Id, path, queryString.QueryString); var obj = new { query_string = queryString.QueryString, id = id.Uuid, allow = queryString.Allow }; return(Core.Environment.Hal.Apply(Defines.QueryStringResource.Guid, obj, false)); }
internal static object ToJsonModel(QueryStringRule queryString, Site site, string path) { if (queryString == null) { return(null); } QueryStringId id = new QueryStringId(site?.Id, path, queryString.QueryString); var obj = new { query_string = queryString.QueryString, id = id.Uuid, allow = queryString.Allow, request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path) }; return(Core.Environment.Hal.Apply(Defines.QueryStringResource.Guid, obj)); }
public object Get(string id) { QueryStringId queryStringId = new QueryStringId(id); Site site = queryStringId.SiteId == null ? null : SiteHelper.GetSite(queryStringId.SiteId.Value); if (queryStringId.SiteId != null && site == null) { return(NotFound()); } QueryStringRule queryString = QueryStringsHelper.GetQueryStrings(site, queryStringId.Path).FirstOrDefault(s => s.QueryString.ToString().Equals(queryStringId.QueryString)); if (queryString == null) { return(NotFound()); } return(QueryStringsHelper.ToJsonModel(queryString, site, queryStringId.Path)); }