예제 #1
1
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            var redId = new RedirectId(id);

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

            if (redId.SiteId != null && site == null)
            {
                return(NotFound());
            }

            string configPath           = model == null ? null : ManagementUnit.ResolveConfigScope(model);
            HttpRedirectSection section = RedirectHelper.GetRedirectSection(site, redId.Path, configPath);

            RedirectHelper.UpdateFeatureSettings(model, section);

            ManagementUnit.Current.Commit();

            return(RedirectHelper.ToJsonModel(site, redId.Path));
        }
예제 #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);
            }
        }