示例#1
0
        public async Task <object> Post()
        {
            if (DefaultDocumentHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(DefaultDocumentHelper.FEATURE_NAME);
            }

            await DefaultDocumentHelper.SetFeatureEnabled(true);

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

            return(Created(DefaultDocumentHelper.GetLocation(settings.id), settings));
        }
示例#2
0
        public async Task Delete(string id)
        {
            DefaultDocumentId docId = new DefaultDocumentId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

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

            if (site != null)
            {
                var section = DefaultDocumentHelper.GetDefaultDocumentSection(site, docId.Path, ManagementUnit.ResolveConfigScope());
                section.RevertToParent();
                ManagementUnit.Current.Commit();
            }

            // When target is webserver, uninstall
            if (docId.SiteId == null && DefaultDocumentHelper.IsFeatureEnabled())
            {
                await DefaultDocumentHelper.SetFeatureEnabled(false);
            }
        }