Esempio n. 1
0
        public object Get(string id)
        {
            CompressionId compId = new CompressionId(id);

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

            return(CompressionHelper.ToJsonModel(site, compId.Path));
        }
Esempio n. 2
0
        public async Task <object> Post()
        {
            if (CompressionHelper.IsStaticEnabled() && CompressionHelper.IsDynamicEnabled())
            {
                throw new AlreadyExistsException(DISPLAY_NAME);
            }

            await CompressionHelper.SetFeatureEnabled(true);

            dynamic compression = CompressionHelper.ToJsonModel(null, null);

            return(Created(CompressionHelper.GetLocation(compression.id), compression));
        }
Esempio n. 3
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

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

            dynamic d = CompressionHelper.ToJsonModel(site, path);

            return(LocationChanged(CompressionHelper.GetLocation(d.id), d));
        }
Esempio n. 4
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            CompressionId compId = new CompressionId(id);

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

            if (compId.SiteId != null && site == null)
            {
                // Targetting section for a site, but unable to find that site
                return(NotFound());
            }

            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);

            CompressionHelper.UpdateSettings(model, site, compId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(CompressionHelper.ToJsonModel(site, compId.Path));
        }