WT1.1.3 logo change, error fixes
This commit is contained in:
@@ -129,14 +129,14 @@ class CustomerRepository with Logging {
|
||||
}
|
||||
|
||||
double getWeight() {
|
||||
return getCustomerProperty("Weight");
|
||||
return getCustomerPropertyValue("Weight");
|
||||
}
|
||||
|
||||
double getHeight() {
|
||||
return getCustomerProperty("Height");
|
||||
return getCustomerPropertyValue("Height");
|
||||
}
|
||||
|
||||
double getCustomerProperty(String propertyName) {
|
||||
double getCustomerPropertyValue(String propertyName) {
|
||||
if (this.customer.properties[propertyName] == null) {
|
||||
return 0.0;
|
||||
} else {
|
||||
@@ -144,6 +144,10 @@ class CustomerRepository with Logging {
|
||||
}
|
||||
}
|
||||
|
||||
CustomerProperty getCustomerProperty(String propertyName) {
|
||||
return this.customer.properties[propertyName];
|
||||
}
|
||||
|
||||
setBirthYear(int birthYear) {
|
||||
this.customer.birthYear = birthYear;
|
||||
}
|
||||
|
||||
@@ -80,17 +80,32 @@ class ExerciseRepository {
|
||||
if (exerciseType.unitQuantity != "1") {
|
||||
modelExercise.unitQuantity = null;
|
||||
}
|
||||
this.actualExerciseList.add(modelExercise);
|
||||
int index = this.actualExerciseList.length - 1;
|
||||
|
||||
Exercise copy = modelExercise.copy();
|
||||
this.actualExerciseList.add(copy);
|
||||
//final int index = this.actualExerciseList.length - 1;
|
||||
//print("$index. actual exercise " + this.actualExerciseList[index].toJson().toString());
|
||||
Exercise savedExercise = await ExerciseApi().addExercise(modelExercise);
|
||||
|
||||
this.actualExerciseList[index].exerciseId = savedExercise.exerciseId;
|
||||
//this.actualExerciseList[index].exerciseId = savedExercise.exerciseId;
|
||||
if (customer.customerId == Cache().userLoggedIn.customerId) {
|
||||
Cache().addExercise(savedExercise);
|
||||
} else if (Cache().getTrainee() != null && customer.customerId == Cache().getTrainee().customerId) {
|
||||
Cache().addExerciseTrainee(savedExercise);
|
||||
}
|
||||
|
||||
/* this.actualExerciseList.forEach((element) {
|
||||
print("$index. actual: " + element.toJson().toString());
|
||||
}); */
|
||||
|
||||
this.createNew();
|
||||
this.exerciseType = exerciseType;
|
||||
this.setUnit(exerciseType.unit);
|
||||
exercise.exerciseTypeId = this.exerciseType.exerciseTypeId;
|
||||
this.setQuantity(quantity);
|
||||
this.setUnitQuantity(modelExercise.unitQuantity);
|
||||
this.exercise.exercisePlanDetailId = 0;
|
||||
this.start = DateTime.now();
|
||||
}
|
||||
|
||||
Future<void> deleteExercise(Exercise exercise) async {
|
||||
@@ -274,7 +289,8 @@ class ExerciseRepository {
|
||||
}
|
||||
String delimiter = "";
|
||||
if (prevCount > 0) delimiter = ", ";
|
||||
summary += delimiter + exercise.quantity.toStringAsFixed(0);
|
||||
double quantity = exercise.quantity == null ? 0 : exercise.quantity;
|
||||
summary += delimiter + quantity.toStringAsFixed(0);
|
||||
ExerciseType exerciseType = Cache().getExercise(exercise.exerciseTypeId);
|
||||
if (exerciseType.unitQuantity == "1") {
|
||||
summary += "x" + exercise.unitQuantity.toStringAsFixed(0);
|
||||
@@ -286,6 +302,5 @@ class ExerciseRepository {
|
||||
prevExercise = exercise;
|
||||
prevCount++;
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,15 +42,17 @@ class ExerciseResultRepository {
|
||||
List<ResultExt> getResults() => this._results;
|
||||
|
||||
Future<void> saveExerciseResults() async {
|
||||
this._results.forEach((result) async {
|
||||
ExerciseResult exerciseResult = ExerciseResult();
|
||||
exerciseResult.customerId = Cache().userLoggedIn.customerId;
|
||||
exerciseResult.exerciseId = result.exerciseId;
|
||||
exerciseResult.dateFrom = result.dateFrom;
|
||||
exerciseResult.dateTo = result.dateTo;
|
||||
exerciseResult.resultType = result.itemString;
|
||||
exerciseResult.value = result.data;
|
||||
await ExerciseResultApi().saveExerciseResult(exerciseResult);
|
||||
});
|
||||
if (this._results != null) {
|
||||
this._results.forEach((result) async {
|
||||
ExerciseResult exerciseResult = ExerciseResult();
|
||||
exerciseResult.customerId = Cache().userLoggedIn.customerId;
|
||||
exerciseResult.exerciseId = result.exerciseId;
|
||||
exerciseResult.dateFrom = result.dateFrom;
|
||||
exerciseResult.dateTo = result.dateTo;
|
||||
exerciseResult.resultType = result.itemString;
|
||||
exerciseResult.value = result.data;
|
||||
//await ExerciseResultApi().saveExerciseResult(exerciseResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,13 +36,33 @@ class UserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addUserFB() async {
|
||||
final User modelUser = this.user;
|
||||
|
||||
Map<String, dynamic> userData = await FirebaseApi().signInWithFacebook();
|
||||
if (userData != null) {
|
||||
modelUser.email = userData['email'];
|
||||
modelUser.password = "1234567";
|
||||
modelUser.firebaseUid = Cache().facebookUid;
|
||||
await CustomerApi().addUser(modelUser);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getUserByFB() async {
|
||||
final User modelUser = this.user;
|
||||
Map<String, dynamic> userData = await FirebaseApi().signInWithFacebook();
|
||||
modelUser.email = userData['email'];
|
||||
await CustomerApi().getUserByEmail(modelUser.email);
|
||||
await Cache().afterFacebookLogin();
|
||||
}
|
||||
|
||||
Future<void> getUser() async {
|
||||
final User modelUser = this.user;
|
||||
String rc = await FirebaseApi().signInEmail(modelUser.email, modelUser.password);
|
||||
|
||||
if (rc == FirebaseApi.SIGN_IN_OK) {
|
||||
await CustomerApi().getUserByEmail(modelUser.email);
|
||||
Cache().afterFirebaseLogin();
|
||||
await Cache().afterFirebaseLogin();
|
||||
} else {
|
||||
print("Exception: user not found or password is wrong");
|
||||
throw Exception("Customer does not exist or the password is wrong");
|
||||
|
||||
Reference in New Issue
Block a user