Initial commit
This commit is contained in:
68
lib/data/mappers/program_mapper.dart
Normal file
68
lib/data/mappers/program_mapper.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user