Exemple #1
0
        public object Post([FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            if (model.http_response_headers == null)
            {
                throw new ApiArgumentException("http_response_headers");
            }
            if (!(model.http_response_headers is JObject))
            {
                throw new ApiArgumentException("http_response_headers");
            }

            string uuid = DynamicHelper.Value(model.http_response_headers.id);

            if (uuid == null)
            {
                throw new ApiArgumentException("http_response_headers.id");
            }

            HttpResponseHeadersId id = new HttpResponseHeadersId(uuid);

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

            string configPath           = ManagementUnit.ResolveConfigScope(model);
            HttpProtocolSection section = HttpResponseHeadersHelper.GetSection(site, id.Path, configPath);

            NameValueConfigurationElement header = CustomHeadersHelper.Create(model, section);

            CustomHeadersHelper.Add(header, section);

            ManagementUnit.Current.Commit();

            //
            // Create response
            dynamic ch = CustomHeadersHelper.ToJsonModel(header, site, id.Path);

            return(Created(CustomHeadersHelper.GetLocation(ch.id), ch));
        }