コード例 #1
0
        public void Delete(string id)
        {
            EntryId entryId = new EntryId(id);

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


            if (entryId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            ModuleHelper.EnsureValidScope(site, entryId.Path);

            Module module = null;

            List <Module> modules = ModuleHelper.GetModules(site, entryId.Path);

            module = modules.FirstOrDefault(m => m.Name.Equals(entryId.Name));

            if (module != null)
            {
                ModuleHelper.DeleteModule(module.Name, site, entryId.Path, ManagementUnit.ResolveConfigScope());
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
        }
コード例 #2
0
        public object Get(string id)
        {
            EntryId entryId = new EntryId(id);

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

            Module module = null;

            // Get the enabled modules
            List <Module> modules = ModuleHelper.GetModules(site, entryId.Path);

            module = modules.FirstOrDefault(m => m.Name.Equals(entryId.Name));

            // Module id did not specify an enabled module
            if (module == null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.NotFound));
            }

            return(ModuleHelper.ModuleToJsonModel(module, site, entryId.Path));
        }
コード例 #3
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            EntryId entryId = new EntryId(id);

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

            if (entryId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            ModuleHelper.EnsureValidScope(site, entryId.Path);

            // Get the enabled modules
            string        configPath = ManagementUnit.ResolveConfigScope(model);
            List <Module> modules    = ModuleHelper.GetModules(site, entryId.Path, configPath);

            Module module = modules.FirstOrDefault(m => m.Name.Equals(entryId.Name));

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

            ModuleHelper.UpdateModule(module, model, site);

            ManagementUnit.Current.Commit();

            //
            // Create response
            dynamic entry = (dynamic)ModuleHelper.ModuleToJsonModel(module, site, entryId.Path);

            if (entry.id != id)
            {
                return(LocationChanged(ModuleHelper.GetModuleEntryLocation(entry.id), entry));
            }

            return(entry);
        }