Exemplo n.º 1
0
        public static ResponseModels.UnitClass Convert(LazyObjects.AFUnit unit)
        {
            ResponseModels.UnitClass result = new ResponseModels.UnitClass(unit.ID, unit.WebID, unit.Name, unit.Description, unit.Path);
            result.CanonicalUnitAbbreviation = unit.Abbreviation;

            return(result);
        }
Exemplo n.º 2
0
        public bool CreateUnitClass(LazyPI.Common.Connection Connection, string AFServerID, LazyObjects.AFUnit UnitClass)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/assetservers/{webId}/unitclasses", Method.POST);

            request.AddUrlSegment("webId", AFServerID);
            ResponseModels.UnitClass body = DataConversions.Convert(UnitClass);
            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);
        }