69 lines
1.9 KiB
Dart
69 lines
1.9 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:trainhub_flutter/data/database/app_database.dart';
|
|
import 'package:trainhub_flutter/domain/entities/program.dart';
|
|
import 'package:trainhub_flutter/domain/entities/program_week.dart';
|
|
import 'package:trainhub_flutter/domain/entities/program_workout.dart';
|
|
|
|
class ProgramMapper {
|
|
ProgramMapper._();
|
|
|
|
static ProgramEntity toEntity(Program row) {
|
|
return ProgramEntity(
|
|
id: row.id,
|
|
name: row.name,
|
|
createdAt: row.createdAt,
|
|
);
|
|
}
|
|
|
|
static ProgramWeekEntity weekToEntity(ProgramWeek row) {
|
|
return ProgramWeekEntity(
|
|
id: row.id,
|
|
programId: row.programId,
|
|
position: row.position,
|
|
notes: row.notes,
|
|
);
|
|
}
|
|
|
|
static ProgramWorkoutEntity workoutToEntity(ProgramWorkout row) {
|
|
return ProgramWorkoutEntity(
|
|
id: row.id,
|
|
weekId: row.weekId,
|
|
programId: row.programId,
|
|
day: row.day,
|
|
type: row.type,
|
|
refId: row.refId,
|
|
name: row.name,
|
|
description: row.description,
|
|
completed: row.completed,
|
|
);
|
|
}
|
|
|
|
static ProgramWorkoutsCompanion workoutToCompanion(
|
|
ProgramWorkoutEntity entity) {
|
|
return ProgramWorkoutsCompanion(
|
|
id: Value(entity.id),
|
|
weekId: Value(entity.weekId),
|
|
programId: Value(entity.programId),
|
|
day: Value(entity.day),
|
|
type: Value(entity.type),
|
|
refId: Value(entity.refId),
|
|
name: Value(entity.name),
|
|
description: Value(entity.description),
|
|
completed: Value(entity.completed),
|
|
);
|
|
}
|
|
|
|
static ProgramWorkoutsCompanion workoutToUpdateCompanion(
|
|
ProgramWorkoutEntity entity) {
|
|
return ProgramWorkoutsCompanion(
|
|
day: Value(entity.day),
|
|
type: Value(entity.type),
|
|
refId: Value(entity.refId),
|
|
name: Value(entity.name),
|
|
description: Value(entity.description),
|
|
completed: Value(entity.completed),
|
|
weekId: Value(entity.weekId),
|
|
);
|
|
}
|
|
}
|