private static DeviceRegistrationResult ConvertToProvisioningRegistrationResult(
            Models.DeviceRegistrationResult result)
        {
            var status = ProvisioningRegistrationStatusType.Failed;

            Enum.TryParse(result.Status, true, out status);

            var substatus = ProvisioningRegistrationSubstatusType.InitialAssignment;

            Enum.TryParse(result.Substatus, true, out substatus);

            return(new DeviceRegistrationResult(
                       result.RegistrationId,
                       result.CreatedDateTimeUtc,
                       result.AssignedHub,
                       result.DeviceId,
                       status,
                       substatus,
                       result.GenerationId,
                       result.LastUpdatedDateTimeUtc,
                       result.ErrorCode == null ? 0 : (int)result.ErrorCode,
                       result.ErrorMessage,
                       result.Etag,
                       result?.Payload?.ToString(CultureInfo.InvariantCulture)));
        }
 /// <summary>
 /// Initializes a new instance of the RegistrationOperationStatus
 /// class.
 /// </summary>
 /// <param name="operationId">Operation ID.</param>
 /// <param name="status">Device enrollment status. Possible values
 /// include: 'unassigned', 'assigning', 'assigned', 'failed',
 /// 'disabled'</param>
 /// <param name="registrationStatus">Device registration
 /// status.</param>
 public RegistrationOperationStatus(
     string operationId = default(string),
     string status      = default(string),
     DeviceRegistrationResult registrationStatus = default(DeviceRegistrationResult))
 {
     OperationId        = operationId;
     Status             = status;
     RegistrationStatus = registrationStatus;
     CustomInit();
 }
        private DeviceRegistrationResult ConvertToProvisioningRegistrationResult(Models.DeviceRegistrationResult result)
        {
            var status = ProvisioningRegistrationStatusType.Failed;

            Enum.TryParse(result.Status, true, out status);

            return(new DeviceRegistrationResult(
                       result.RegistrationId,
                       result.CreatedDateTimeUtc,
                       result.AssignedHub,
                       result.DeviceId,
                       status,
                       result.GenerationId,
                       result.LastUpdatedDateTimeUtc,
                       result.ErrorCode == null ? 0 : (int)result.ErrorCode,
                       result.ErrorMessage,
                       result.Etag));
        }