insertNewTime method
- TimeTraining timeTraining
Método para insertar un nuevo tiempo de entrenamiento.
Este método inserta un nuevo tiempo de entrenamiento en la base de datos.
Parámetros:
timeTraining
: Objeto de tipo TimeTraining que contiene los datos del nuevo tiempo de entrenamiento.
Retorna:
bool
:true
si la inserción fue exitosa,false
si ocurrió un error.
Implementation
Future<bool> insertNewTime(TimeTraining timeTraining) async {
final db = await DatabaseHelper.database;
try {
final result = await db.insert('timeTraining', {
'idSession': timeTraining.idSession,
'scramble': timeTraining.scramble,
'timeInSeconds': timeTraining.timeInSeconds,
'comments': timeTraining.comments,
'penalty': timeTraining.penalty,
'registrationDate': timeTraining.registrationDate
});
if (result > 0) {
return true; // SE INSERTO CORRECTAMENTE
} else {
return false; // NO SE INSERTO CORRECTAMENTE
} // VERIFICAMOS SI SE HA INSERTADO CORRECTAMENTE
} catch (e) {
DatabaseHelper.logger.e("Error al insertar un nuevo registro: $e");
return false; // DEVUELVE FALSE EN CASO DE ERROR
}
}