public object Get() { string requestFilteringUuid = Context.Request.Query[Defines.IDENTIFIER]; if (string.IsNullOrEmpty(requestFilteringUuid)) { return(NotFound()); } RequestFilteringId reqId = new RequestFilteringId(requestFilteringUuid); Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value); List <Extension> extensions = ExtensionsHelper.GetExtensions(site, reqId.Path); return(new { file_extensions = extensions.Select(e => ExtensionsHelper.ToJsonModelRef(e, site, reqId.Path)) }); }
public object Get(string id) { ExtensionId extId = new ExtensionId(id); Site site = extId.SiteId == null ? null : SiteHelper.GetSite(extId.SiteId.Value); if (extId.SiteId != null && site == null) { return(NotFound()); } Extension extension = ExtensionsHelper.GetExtensions(site, extId.Path).Where(e => e.FileExtension.Equals(extId.FileExtension)).FirstOrDefault(); if (extension == null) { return(NotFound()); } return(ExtensionsHelper.ToJsonModel(extension, site, extId.Path)); }
public object Patch(string id, [FromBody] dynamic model) { ExtensionId extId = new ExtensionId(id); Site site = extId.SiteId == null ? null : SiteHelper.GetSite(extId.SiteId.Value); if (extId.SiteId != null && site == null) { return(new StatusCodeResult((int)HttpStatusCode.NotFound)); } if (model == null) { throw new ApiArgumentException("model"); } string configPath = ManagementUnit.ResolveConfigScope(model); Extension extension = ExtensionsHelper.GetExtensions(site, extId.Path, configPath). FirstOrDefault(e => e.FileExtension.ToString().Equals(extId.FileExtension)); if (extension == null) { return(NotFound()); } extension = ExtensionsHelper.UpdateExtension(extension, model); ManagementUnit.Current.Commit(); dynamic ext = ExtensionsHelper.ToJsonModel(extension, site, extId.Path); if (ext.id != id) { return(LocationChanged(ExtensionsHelper.GetLocation(ext.id), ext)); } return(ext); }
public void Delete(string id) { ExtensionId extId = new ExtensionId(id); Site site = extId.SiteId == null ? null : SiteHelper.GetSite(extId.SiteId.Value); if (extId.SiteId != null && site == null) { Context.Response.StatusCode = (int)HttpStatusCode.NoContent; return; } Extension extension = ExtensionsHelper.GetExtensions(site, extId.Path).Where(e => e.FileExtension.ToString().Equals(extId.FileExtension)).FirstOrDefault(); if (extension != null) { var section = RequestFilteringHelper.GetRequestFilteringSection(site, extId.Path, ManagementUnit.ResolveConfigScope()); ExtensionsHelper.DeleteExtension(extension, section); ManagementUnit.Current.Commit(); } Context.Response.StatusCode = (int)HttpStatusCode.NoContent; }