private List <HardwareTemplate> BAM_ApiPost(HardwareTemplate newTemplate, HardwareTemplate originalTemplate, List <HardwareTemplate> returnValue, Models.HardwareTemplate_Json template) { var jsonSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var json = JsonConvert.SerializeObject(template);//, jsonSettings var content = new StringContent(JsonConvert.SerializeObject(template), Encoding.UTF8, "application/json"); var queryResult_Set = _bamclient._client.PostAsync("api/V3/Projection/Commit", content).Result; if (!queryResult_Set.IsSuccessStatusCode) { string responseContent = queryResult_Set.Content.ReadAsStringAsync().Result; ExceptionResponse exceptionResponse = JsonConvert.DeserializeObject <ExceptionResponse>(responseContent); //throw new Exception(exceptionResponse.Exception); } var resultSring = queryResult_Set.Content.ReadAsStringAsync().Result; //var result = JsonConvert.DeserializeObject<List<BAM_HardwareTemplate>>(resultSring); /////-------------This could be moved out and converted into an async Task ---- we can handle response outside/// var result = JsonConvert.DeserializeObject <BAM_Api_SuccessResponse>(resultSring); //if (result.BaseId != newTemplate.BaseId) // throw new Exception("Updated BaseId's didn't match"); returnValue.Add(newTemplate); returnValue.Add(originalTemplate); return(returnValue); }
public HardwareTemplate SetAssetTag(HardwareTemplate template, string assetTag) { if (template == null) { throw new Exception("Template must not be null"); } // Clone the object so we can check the changes var newHardwareAsset = CloneObject.Clone(template); newHardwareAsset.AssetTag = assetTag; return(newHardwareAsset); }
public HardwareTemplate SetHardwareAssetStatus(HardwareTemplate template, EST_HWAssetStatus hWAssetStatus) { if (template == null) { throw new Exception("Template must not be null"); } // Clone the object so we can check the changes var newHardwareAsset = CloneObject.Clone(template); newHardwareAsset.HardwareAssetStatus = _assetStatusService.GetAssetStatusTemplate(hWAssetStatus); return(newHardwareAsset); }
public List <HardwareTemplate> UpdateTemplate(HardwareTemplate newTemplate, HardwareTemplate originalTemplate) { var returnValue = new List <HardwareTemplate>(); if (newTemplate == null) { throw new Exception("Template must not be null"); } // Set API NameRelationship default values newTemplate.NameRelationship = _bamApiRelationships; var template = new HardwareTemplate_Json() { formJson = new FormJson() { Original = originalTemplate, Current = newTemplate } }; return(BAM_ApiPost(newTemplate, originalTemplate, returnValue, template)); }
public static HardwareTemplate_Full Map_Results(HardwareTemplate record) { return(Mapper.Map <HardwareTemplate, HardwareTemplate_Full>(record)); }