import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/rate/appointment_details.dart'; import 'package:diplomaticquarterapp/core/model/rate/appointment_rate.dart'; import 'package:diplomaticquarterapp/core/model/rate/appoitment_rated.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class AppointmentRateService extends BaseService { List 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 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; appointmentRate.createdBy = 2; appointmentRate.editedBy = 2; await baseAppClient.post(NEW_RATE_APPOINTMENT_URL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: appointmentRate.toJson()); } Future sendDoctorRate(int rate, int appointmentNo, int projectID, int doctorID, int clinicID, String note, String appoDate, String docName, String projectName, String clinicName) async { Map request; hasError = false; request = { "DoctorID": doctorID, "Rate": rate, "ClinicID": clinicID, "ProjectID": projectID, "AppointmentNo": appointmentNo, "Note": note, "MobileNumber": authenticatedUserObject.user.mobileNumber, "AppointmentDate": appoDate, "DoctorName": docName, "ProjectName": projectName, "COCTypeName": 1, "PatientName": authenticatedUserObject.user.firstName + " " + authenticatedUserObject.user.lastName, "PatientOutSA": authenticatedUserObject.user.outSA, "PatientTypeID": authenticatedUserObject.user.patientType, "ClinicName": clinicName, "PatientIdentificationID": authenticatedUserObject.user.patientIdentificationNo }; await baseAppClient.post(NEW_RATE_DOCTOR_URL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: request); } AppoitmentRated get lastAppointmentRated { if (appointmentRatedList.length > 0) return appointmentRatedList[appointmentRatedList.length - 1]; return null; } deleteAppointmentRated(AppoitmentRated appointmentRated) { appointmentRatedList.remove(appointmentRated); } deleteAllAppAppointmentRate() => appointmentRatedList.clear(); }