Example #1
0
        public async Task <object> Post()
        {
            if (RedirectHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(RedirectHelper.FEATURE);
            }

            await RedirectHelper.SetFeatureEnabled(true);

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

            return(Created(RedirectHelper.GetLocation(settings.id), settings));
        }
Example #2
0
        public async Task Delete(string id)
        {
            var redId = new RedirectId(id);

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

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

            if (site != null)
            {
                var section = RedirectHelper.GetRedirectSection(site, redId.Path, ManagementUnit.ResolveConfigScope());
                section.RevertToParent();
                ManagementUnit.Current.Commit();
            }

            if (redId.SiteId == null && RedirectHelper.IsFeatureEnabled())
            {
                await RedirectHelper.SetFeatureEnabled(false);
            }
        }