mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Move PerformanceModel to database
This commit is contained in:
parent
7f783bd016
commit
8c36988da9
2 changed files with 20 additions and 13 deletions
|
|
@ -17,6 +17,18 @@ class WorkModel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PerformanceModel {
|
||||||
|
final Person person;
|
||||||
|
final Ensemble ensemble;
|
||||||
|
final Role role;
|
||||||
|
|
||||||
|
PerformanceModel({
|
||||||
|
this.person,
|
||||||
|
this.ensemble,
|
||||||
|
this.role,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@UseMoor(
|
@UseMoor(
|
||||||
include: {
|
include: {
|
||||||
'database.moor',
|
'database.moor',
|
||||||
|
|
@ -75,14 +87,19 @@ class Database extends _$Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateRecording(
|
Future<void> updateRecording(
|
||||||
Recording recording, List<Performance> perfs) async {
|
Recording recording, List<PerformanceModel> models) async {
|
||||||
await transaction(() async {
|
await transaction(() async {
|
||||||
await (delete(performances)
|
await (delete(performances)
|
||||||
..where((p) => p.recording.equals(recording.id)))
|
..where((p) => p.recording.equals(recording.id)))
|
||||||
.go();
|
.go();
|
||||||
await into(recordings).insert(recording, orReplace: true);
|
await into(recordings).insert(recording, orReplace: true);
|
||||||
for (final perf in perfs) {
|
for (final model in models) {
|
||||||
await into(performances).insert(perf);
|
await into(performances).insert(Performance(
|
||||||
|
recording: recording.id,
|
||||||
|
person: model.person.id,
|
||||||
|
ensemble: model.ensemble.id,
|
||||||
|
role: model.role.id,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,6 @@ import '../database.dart';
|
||||||
import '../editors/person.dart';
|
import '../editors/person.dart';
|
||||||
import '../selectors/role.dart';
|
import '../selectors/role.dart';
|
||||||
|
|
||||||
class PerformanceModel {
|
|
||||||
final Person person;
|
|
||||||
final Role role;
|
|
||||||
|
|
||||||
PerformanceModel({
|
|
||||||
this.person,
|
|
||||||
this.role,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Allow selecting and adding ensembles.
|
// TODO: Allow selecting and adding ensembles.
|
||||||
// TODO: Allow selecting instruments as roles.
|
// TODO: Allow selecting instruments as roles.
|
||||||
class PerformerSelector extends StatefulWidget {
|
class PerformerSelector extends StatefulWidget {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue