Esempio n. 1
0
        public async Task <object> Post()
        {
            if (AuthorizationHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(AuthorizationHelper.FEATURE_NAME);
            }

            await AuthorizationHelper.SetFeatureEnabled(true);

            dynamic auth = AuthorizationHelper.ToJsonModel(null, null);

            return(Created(AuthorizationHelper.GetLocation(auth.id), auth));
        }
Esempio n. 2
0
        public async Task Delete(string id)
        {
            AuthorizationId authId = new AuthorizationId(id);

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

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

            if (site != null)
            {
                var section = AuthorizationHelper.GetSection(site, authId.Path, ManagementUnit.ResolveConfigScope());
                section.RevertToParent();
                ManagementUnit.Current.Commit();
            }

            if (authId.SiteId == null && AuthorizationHelper.IsFeatureEnabled())
            {
                await AuthorizationHelper.SetFeatureEnabled(false);
            }
        }