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); }
/// <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); 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 == 201); }