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/service/appointment_rate_service.dart

72 lines
2.7 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/rate/appointment_rate.dart';
import 'package:diplomaticquarterapp/core/model/rate/appoitment_rated.dart';
import 'package:diplomaticquarterapp/core/model/rate/appointment_details.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
class AppointmentRateService extends BaseService {
List<AppoitmentRated> appointmentRatedList = List();
AppointmentDetails appointmentDetails;
Future getIsLastAppointmentRatedList() async {
hasError = false;
await baseAppClient.post(IS_LAST_APPOITMENT_RATED,
onSuccess: (dynamic response, int statusCode) {
appointmentRatedList.clear();
response['IsLastAppoitmentRatedList'].forEach((appoint) {
appointmentRatedList.add(AppoitmentRated.fromJson(appoint));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
Future getAppointmentDetails() async {
hasError = false;
Map<String, dynamic> bodyData = Map();
bodyData['AppointmentNumber'] = appointmentRatedList[0].appointmentNo;
bodyData['ProjectID'] = appointmentRatedList[0].projectID;
await baseAppClient.post(GET_APPOINTMENT_DETAILS_BY_NO,
onSuccess: (dynamic response, int statusCode) {
if (response['AppointmentDetails'] != null)
appointmentDetails =
AppointmentDetails.fromJson(response['AppointmentDetails']);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: bodyData);
}
Future sendAppointmentRate(int rate, int appointmentNo, int projectID,
int doctorID, int clinicID, String note) async {
hasError = false;
AppointmentRate appointmentRate = AppointmentRate();
appointmentRate.rate = rate;
appointmentRate.appointmentNo = appointmentNo;
appointmentRate.projectID = projectID;
appointmentRate.doctorID = doctorID;
appointmentRate.clinicID = clinicID;
appointmentRate.note = note;
await baseAppClient.post(GET_APPOINTMENT_DETAILS_BY_NO,
onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: appointmentRate.toJson());
}
AppoitmentRated get lastAppointmentRated {
if (appointmentRatedList.length > 0)
return appointmentRatedList[appointmentRatedList.length - 1];
return null;
}
deleteAppointmentRated(AppoitmentRated appointmentRated) {
appointmentRatedList.remove(appointmentRated);
}
deleteAllAppAppointmentRate() => appointmentRatedList.clear();
}