You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../locator.dart';
|
|
|
|
|
|
|
|
|
|
class PrescriptionViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
|
|
PrescriptionService _prescriptionService = locator<PrescriptionService>();
|
|
|
|
|
|
|
|
|
|
List<Prescriptions> get prescriptionsList =>
|
|
|
|
|
_prescriptionService.prescriptionsList;
|
|
|
|
|
|
|
|
|
|
getPrescription() async {
|
|
|
|
|
await getSavedLanguage();
|
|
|
|
|
prescriptionsList.clear();
|
|
|
|
|
if(prescriptionsList.isEmpty){
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _prescriptionService.getPrescription();
|
|
|
|
|
if (_prescriptionService.hasError) {
|
|
|
|
|
error = _prescriptionService.error;
|
|
|
|
|
setState(ViewState.Error);
|
|
|
|
|
} else {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|