While writing codes you need to convert it according to your requirement
For doing that you can do typecasting of the operands
Public Function GetFriendsToNudge(ByVal accessToken As String) As UsersResponse
Dim reader As SqlDataReader
Dim users As New Users()
Dim usersResponse As New UsersResponse()
Try
Using sqlConnection As New SqlConnection(ConnectionString)
If sqlConnection.State = ConnectionState.Closed Then
sqlConnection.Open()
End If
Dim parameterList As New List(Of SqlParameter)()
parameterList.Add(New SqlParameter("@AccessToken", accessToken))
reader = BaseRepository.ExecuteReader(sqlConnection, CommandType.StoredProcedure, "uspGetFriendsToNudge", parameterList.ToArray())
If reader.HasRows Then
While reader.Read()
users.users.Add(New User() With {
.Id = If(reader("ID") IsNot Nothing, If(Not String.IsNullOrEmpty(Convert.ToString(reader("ID"))), Convert.ToInt32(Convert.ToString(reader("ID")).Trim()), 0), 0),
.FullName = If(reader("Friend") IsNot Nothing, Convert.ToString(reader("Friend")).Trim(), String.Empty)
})
End While
usersResponse.Status = True
usersResponse.Message = "Friends successfully fetched."
Else
usersResponse.Status = False
usersResponse.Message = KnownConstants.UnauthorizedMessage
End If
End Using
Catch ex As Exception
Logger.LogException(ex)
usersResponse.Status = False
usersResponse.Message = "Error occurred while getting friends."
End Try
usersResponse.data = users
Return usersResponse
End Function
In this code type conversion and checking both are done at the coding end using ternary operators
0 Comment(s)