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.
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import '../models/list_doctor_working_hours_table_model.dart';
|
|
import '../models/request_schedule.dart';
|
|
|
|
class ScheduleProvider with ChangeNotifier {
|
|
List<ListDoctorWorkingHoursTable> listDoctorWorkingHoursTable = [];
|
|
bool isLoading = true;
|
|
bool isError = false;
|
|
String error = '';
|
|
RequestSchedule requestSchedule = RequestSchedule();
|
|
|
|
ScheduleProvider() {
|
|
getDoctorSchedule();
|
|
}
|
|
|
|
getDoctorSchedule() async {
|
|
try {
|
|
await BaseAppClient.post('Doctors.svc/REST/GetDoctorWorkingHoursTable',
|
|
body: requestSchedule.toJson(),
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
response['List_DoctorWorkingHoursTable'].forEach((v) {
|
|
listDoctorWorkingHoursTable.add(new ListDoctorWorkingHoursTable.fromJson(v));
|
|
});
|
|
isError = false;
|
|
isLoading = false;
|
|
}, onFailure: (String error, int statusCode) {
|
|
isLoading = false;
|
|
isError = true;
|
|
this.error = error;
|
|
});
|
|
notifyListeners();
|
|
} catch (e) {
|
|
isLoading = false;
|
|
isError = true;
|
|
error = 'Something wrong happened, please contact the admin';
|
|
notifyListeners();
|
|
}
|
|
}
|
|
}
|