public async Task Delete(string id) { IPRestrictionId ipId = new IPRestrictionId(id); Context.Response.StatusCode = (int)HttpStatusCode.NoContent; Site site = (ipId.SiteId != null) ? SiteHelper.GetSite(ipId.SiteId.Value) : null; if (site != null) { IPRestrictionsHelper.GetSection(site, ipId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); if (ManagementUnit.ServerManager.GetApplicationHostConfiguration().HasSection(IPRestrictionsGlobals.DynamicIPSecuritySectionName)) { IPRestrictionsHelper.GetDynamicSecuritySection(site, ipId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); } ManagementUnit.Current.Commit(); } if (ipId.SiteId == null && IPRestrictionsHelper.IsFeatureEnabled()) { await IPRestrictionsHelper.SetFeatureEnabled(false); } }
public async Task <object> Post() { if (IPRestrictionsHelper.IsFeatureEnabled()) { throw new AlreadyExistsException(IPRestrictionsHelper.FEATURE_NAME); } await IPRestrictionsHelper.SetFeatureEnabled(true); dynamic settings = IPRestrictionsHelper.ToJsonModel(null, null); return(Created(IPRestrictionsHelper.GetLocation(settings.id), settings)); }