コード例 #1
0
        public object Get()
        {
            RewriteHelper.ResolveRewrite(Context, out Site site, out string path);

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

            dynamic d = ProvidersHelper.SectionToJsonModel(site, path);

            return(LocationChanged(ProvidersHelper.GetSectionLocation(d.id), d));
        }
コード例 #2
0
        public object Get(string id)
        {
            var rewriteId = new RewriteId(id);

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

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

            return(ProvidersHelper.SectionToJsonModel(site, rewriteId.Path));
        }
コード例 #3
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            var providersId = new RewriteId(id);

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

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

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

            ProvidersHelper.UpdateSection(model, site, providersId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(ProvidersHelper.SectionToJsonModel(site, providersId.Path));
        }