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.
diplomatic-quarter/lib/core/viewModels/pharmacyModule/lacum-registration-viewMode...

56 lines
1.9 KiB
Dart

import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/ListUserAgreement.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/lacum-registration-service.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/lacum-transfer-service.dart';
import '../../../locator.dart';
import 'lacum-viewmodel.dart';
class LacumRegistrationViewModel extends LacumViewModel {
LacumRegistrationService _lacumService = locator<LacumRegistrationService>();
ListUserAgreement get listUserAgreement => _lacumService.listUserAgreement;
Future checkLacumAccountActivation(String patientIdentificationNo) async {
setState(ViewState.Busy);
await _lacumService.getLacumAccountInformationById(patientIdentificationNo);
if (_lacumService.hasError) {
error = _lacumService.error;
setState(ViewState.Error);
} else {
if(_lacumService.lacumInformation.yahalaAccountNo != 0){
error = "The account has already been activated";
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
}
Future getUserTermsAndConditionsForEPharmcy() async {
setState(ViewState.Busy);
await _lacumService.getUserTermsAndConditionsForEPharmcy();
if (_lacumService.hasError) {
error = _lacumService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
Future<int> createNewLakumAccount(String name, String phone, String identificationNo, int languageId) async {
setState(ViewState.Busy);
await _lacumService.createLakumAccount(name, phone, 0, identificationNo, languageId);
if (_lacumService.hasError) {
error = _lacumService.error;
setState(ViewState.Error);
return 404;
} else {
setState(ViewState.Idle);
return 200;
}
}
}