public static ResponseModels.AFAttribute Convert(LazyObjects.AFAttribute Attrbute) { ResponseModels.AFAttribute result = new ResponseModels.AFAttribute(Attrbute.ID, Attrbute.WebID, Attrbute.Name, Attrbute.Description, Attrbute.Path); //result.CategoryNames = Attrbute.Categories.ToList(); result.ConfigString = Attrbute.ConfigString; result.DataReferencePlugIn = Attrbute.DataReferencePlugIn; result.Type = Attrbute.Type; return(result); }
public bool CreateAttribute(LazyPI.Common.Connection Connection, string FrameID, LazyObjects.AFAttribute attribute) { WebAPIConnection webConnection = (WebAPIConnection)Connection; var request = new RestRequest("/eventframes/{webId}/attributes", Method.POST); request.AddUrlSegment("webId", FrameID); ResponseModels.AFAttribute body = DataConversions.Convert(attribute); request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody); var statusCode = webConnection.Client.Execute(request).StatusCode; return((int)statusCode == 201 ? true : false); }
/// <summary> /// Update an attribute by replacing items in its definition. /// </summary> /// <param name="Attr">A partial attribute that contains the WebID and any properties to be updated.</param> /// <returns>Returns true if update completed.</returns> public bool Update(LazyPI.Common.Connection Connection, LazyObjects.AFAttribute Attr) { WebAPIConnection webConnection = (WebAPIConnection)Connection; var request = new RestRequest("/attributes/{webId}", Method.PATCH); request.AddUrlSegment("webId", Attr.WebID); ResponseModels.AFAttribute body = DataConversions.Convert(Attr); request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody); var statusCode = webConnection.Client.Execute(request).StatusCode; return((int)statusCode == 204); }
/// <summary> /// Creates a new AFAttribute in the parent element referenced by parentWID. /// </summary> /// <param name="ParentID"></param> /// <param name="Attr">The definition of the new attribute.</param> /// <returns>Returns true if create completed.</returns> public bool Create(LazyPI.Common.Connection Connection, string ParentID, LazyObjects.AFAttribute Attr) { WebAPIConnection webConnection = (WebAPIConnection)Connection; var request = new RestRequest("/attributes/{webId}", Method.POST); request.AddUrlSegment("webId", ParentID); //Copy to api object ResponseModels.AFAttribute clientAttr = new ResponseModels.AFAttribute(); clientAttr.Name = Attr.Name; clientAttr.Description = Attr.Description; request.AddBody(clientAttr); var statusCode = webConnection.Client.Execute(request).StatusCode; return ((int)statusCode == 201); }
/// <summary> /// Creates a new AFAttribute in the parent element referenced by parentWID. /// </summary> /// <param name="ParentID"></param> /// <param name="Attr">The definition of the new attribute.</param> /// <returns>Returns true if create completed.</returns> public bool Create(LazyPI.Common.Connection Connection, string ParentID, LazyObjects.AFAttribute Attr) { WebAPIConnection webConnection = (WebAPIConnection)Connection; var request = new RestRequest("/attributes/{webId}", Method.POST); request.AddUrlSegment("webId", ParentID); //Copy to api object ResponseModels.AFAttribute clientAttr = new ResponseModels.AFAttribute(); clientAttr.Name = Attr.Name; clientAttr.Description = Attr.Description; request.AddBody(clientAttr); var statusCode = webConnection.Client.Execute(request).StatusCode; return((int)statusCode == 201); }