Exemplo n.º 1
0
        public object Get(string id)
        {
            MappingId mappingId = new MappingId(id);

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

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

            Mapping mapping = MappingsHelper.GetMappings(site, mappingId.Path).FirstOrDefault(u => u.Name.Equals(mappingId.Name));

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

            return(MappingsHelper.ToJsonModel(mapping, site, mappingId.Path));
        }
Exemplo n.º 2
0
        public object Get()
        {
            string HandlersUuid = Context.Request.Query[Defines.IDENTIFIER];

            if (string.IsNullOrEmpty(HandlersUuid))
            {
                return(NotFound());
            }

            HandlersId id = new HandlersId(HandlersUuid);

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

            List <Mapping> mappings = MappingsHelper.GetMappings(site, id.Path);

            // Set HTTP header for total count
            this.Context.Response.SetItemsCount(mappings.Count());

            Fields fields = Context.Request.GetFields();

            return(new {
                entries = mappings.Select(mapping => MappingsHelper.ToJsonModelRef(mapping, site, id.Path, fields))
            });
        }
Exemplo n.º 3
0
        public void Delete(string id)
        {
            MappingId mappingId = new MappingId(id);

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

            if (mappingId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            Mapping mapping = MappingsHelper.GetMappings(site, mappingId.Path).FirstOrDefault(u => u.Name.Equals(mappingId.Name));

            if (mapping != null)
            {
                var section = HandlersHelper.GetHandlersSection(site, mappingId.Path, ManagementUnit.ResolveConfigScope());

                MappingsHelper.DeleteMapping(mapping, section);
                ManagementUnit.Current.Commit();
            }

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