public IActionResult GetEquipment(string id) { ViewModels.Equipment result = null; if (!string.IsNullOrEmpty(id) && Guid.TryParse(id, out Guid equipmentId)) { // query the Dynamics system to get the Equipment record. MicrosoftDynamicsCRMbcgovEquipment equipment = _dynamicsClient.GetEquipmentByIdWithChildren(equipmentId); if (equipment != null) { result = equipment.ToViewModel(); } else { return(new NotFoundResult()); } } else { return(BadRequest()); } return(Json(result)); }