Exemplo n.º 1
0
        public IEnumerable <LazyObjects.AFAttributeTemplate> GetAttributeTemplates(LazyPI.Common.Connection Connection, string ElementID)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/elementtemplates/{webId}/attributetemplates");

            request.AddUrlSegment("webId", ElementID);

            var response = webConnection.Client.Execute <ResponseModels.ResponseList <ResponseModels.AFAttributeTemplate> >(request);

            if (response.ErrorException != null)
            {
                throw new ApplicationException("Error finding element templates for element. (See Inner Details)", response.ErrorException);
            }

            var data = response.Data;

            List <LazyObjects.AFAttributeTemplate> results = new List <LazyObjects.AFAttributeTemplate>();

            foreach (var template in data.Items)
            {
                LazyObjects.AFAttributeTemplate attr = new LazyObjects.AFAttributeTemplate(Connection, template.WebId, template.Id, template.Name, template.Description, template.Path);
                results.Add(attr);
            }

            return(results);
        }
Exemplo n.º 2
0
        //This really creates a childe attributetemplate
        //TODO: Something is wrong here ID should be a parent ID
        public bool Create(LazyPI.Common.Connection Connection, LazyObjects.AFAttributeTemplate AttrTemp)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/attributetemplates/{webId}/attributetemplates");

            request.AddUrlSegment("webId", AttrTemp.WebID);
            request.AddBody(AttrTemp);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 201);
        }