public object Get(string id)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

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

            return(DirectoryBrowsingHelper.ToJsonModel(site, dirbId.Path));
        }
        public async Task <object> Post()
        {
            if (DirectoryBrowsingHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(DISPLAY_NAME);
            }

            await DirectoryBrowsingHelper.SetFeatureEnabled(true);

            dynamic settings = DirectoryBrowsingHelper.ToJsonModel(null, null);

            return(Created(DirectoryBrowsingHelper.GetLocation(settings.id), settings));
        }
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

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

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

            return(LocationChanged(DirectoryBrowsingHelper.GetLocation(d.id), d));
        }
        public object Patch(string id, [FromBody] dynamic model)
        {
            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(id);

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

            if (dirbId.SiteId != null && site == null)
            {
                return(NotFound());
            }

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

            DirectoryBrowsingHelper.UpdateSettings(model, site, dirbId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(DirectoryBrowsingHelper.ToJsonModel(site, dirbId.Path));
        }