import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/my_trakers/weight/MonthWeightMeasurementResultAverage.dart'; import 'package:diplomaticquarterapp/core/model/my_trakers/weight/WeekWeightMeasurementResultAverage.dart'; import 'package:diplomaticquarterapp/core/model/my_trakers/weight/WeightMeasurementResult.dart'; import 'package:diplomaticquarterapp/core/model/my_trakers/weight/YearWeightMeasurementResultAverage.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class WeightService extends BaseService { ///Average List monthWeightMeasurementResultAverage = List(); List weekWeightMeasurementResultAverage = List(); List yearWeightMeasurementResultAverage = List(); ///Result List monthWeightMeasurementResult = List(); List weekWeightMeasurementResult = List(); List yearWeightMeasurementResult = List(); Future getWeightAverage() async { hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; await baseAppClient.post(GET_WEIGHT_PRESSURE_RESULT_AVERAGE, onSuccess: (dynamic response, int statusCode) { monthWeightMeasurementResultAverage.clear(); weekWeightMeasurementResultAverage.clear(); yearWeightMeasurementResultAverage.clear(); response['List_MonthWeightMeasurementResultAverage'].forEach((item) { monthWeightMeasurementResultAverage .add(MonthWeightMeasurementResultAverage.fromJson(item)); }); response['List_WeekWeightMeasurementResultAverage'].forEach((item) { weekWeightMeasurementResultAverage .add(WeekWeightMeasurementResultAverage.fromJson(item)); }); response['List_YearWeightMeasurementResultAverage'].forEach((item) { yearWeightMeasurementResultAverage .add(YearWeightMeasurementResultAverage.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } Future getWeightMeasurementResult() async { hasError = false; await baseAppClient.post(GET_WEIGHT_PRESSURE_RESULT, onSuccess: (dynamic response, int statusCode) { monthWeightMeasurementResult.clear(); weekWeightMeasurementResult.clear(); yearWeightMeasurementResult.clear(); response['List_WeekWeightMeasurementResult'].forEach((item) { weekWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item)); }); response['List_MonthWeightMeasurementResult'].forEach((item) { monthWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item)); }); response['List_YearWeightMeasurementResult'].forEach((item) { yearWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: Map()); } addWeightResult( {String weightDate, String weightMeasured, int weightUnit}) async { hasError = false; super.error = ""; Map body = Map(); body['WeightDate'] = weightDate; body['WeightMeasured'] = weightMeasured; body['weightUnit'] = weightUnit; body['isDentalAllowedBackend'] = false; await baseAppClient.post(ADD_WEIGHT_PRESSURE_RESULT, onSuccess: (response, statusCode) async { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } }