示例#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 object Get(string id)
        {
            var redId = new RedirectId(id);

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

            return(RedirectHelper.ToJsonModel(site, redId.Path));
        }
示例#3
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));
        }
示例#4
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            if (path == null)
            {
                return(NotFound());
            }

            dynamic d = RedirectHelper.ToJsonModel(site, path);

            return(LocationChanged(RedirectHelper.GetLocation(d.id), d));
        }