WT 1.1.14 Tutorial, Sports, New goals

This commit is contained in:
bossanyit
2021-05-02 17:12:42 +02:00
parent 5fe8f76f48
commit c901b07bf8
65 changed files with 2472 additions and 620 deletions
+44
View File
@@ -6,6 +6,7 @@ import 'package:aitrainer_app/model/customer_property.dart';
import 'package:aitrainer_app/model/product_test.dart';
import 'package:aitrainer_app/model/property.dart';
import 'package:aitrainer_app/model/purchase.dart';
import 'package:aitrainer_app/model/sport.dart';
import 'package:aitrainer_app/repository/property_repository.dart';
import 'package:aitrainer_app/service/customer_service.dart';
import 'package:aitrainer_app/service/logging.dart';
@@ -90,6 +91,36 @@ class CustomerRepository with Logging {
return this.customer!.goal;
}
String? getSportString() {
if (this.customer == null) throw Exception("Initialize the customer object");
String? sport;
List<Sport>? sports = Cache().getSports();
if (sports != null) {
for (Sport sportObject in sports) {
if (sportObject.sportId == this.customer!.sportId) {
sport = sportObject.name;
break;
}
}
}
return sport;
}
Sport? getSport() {
if (this.customer == null) throw Exception("Initialize the customer object");
Sport? sport;
List<Sport>? sports = Cache().getSports();
if (sports != null) {
for (Sport sportObject in sports) {
if (sportObject.sportId == this.customer!.sportId) {
sport = sportObject;
break;
}
}
}
return sport;
}
String? get fitnessLevel {
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.fitnessLevel;
@@ -189,6 +220,19 @@ class CustomerRepository with Logging {
this.customer!.goal = goal;
}
setSportString(String selectedSport) {
if (this.customer == null) throw Exception("Initialize the customer object");
List<Sport>? sports = Cache().getSports();
if (sports != null) {
for (Sport sportObject in sports) {
if (sportObject.name == selectedSport) {
this.customer!.sportId = sportObject.sportId;
break;
}
}
}
}
setBodyType(String bodyType) {
if (this.customer == null) throw Exception("Initialize the customer object");
this.customer!.bodyType = bodyType;
+3
View File
@@ -74,6 +74,9 @@ class ExerciseRepository {
Exercise? getExercise() => this.exercise;
Future<Exercise> addExercise() async {
if (this.customer == null) {
throw Exception("Please log in");
}
final Exercise modelExercise = this.exercise!;
modelExercise.customerId = this.customer!.customerId;
modelExercise.exerciseTypeId = this.exerciseType!.exerciseTypeId;