From fe1885b367fa1850d7c0cc4b405d99c5c54bb088 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Tue, 5 Sep 2023 12:04:45 +0300 Subject: [PATCH] Fix asset destination issue --- .../api/device_transfer_provider.dart | 16 +++++++---- lib/models/device/device_transfer_info.dart | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lib/controllers/providers/api/device_transfer_provider.dart b/lib/controllers/providers/api/device_transfer_provider.dart index 2c6e2b37..9dbe79b4 100644 --- a/lib/controllers/providers/api/device_transfer_provider.dart +++ b/lib/controllers/providers/api/device_transfer_provider.dart @@ -202,8 +202,11 @@ class DeviceTransferProvider extends ChangeNotifier { "senderEndDate": newModel.timer?.endAt?.toIso8601String(), "senderTravelingHours": newModel.travelingHours, "senderAttachmentName": newModel?.signature ?? "", - "destSiteId": oldModel.receiver.client.id, - "destDepartmentId": oldModel.receiver.department.id, + "destSiteId": oldModel.receiver.client?.id, + "destDepartmentId": oldModel.receiver.department?.id, + "destBuildingId": oldModel.receiver.building?.id, + "destFloorId": oldModel.receiver.floor?.id, + "destRoom": oldModel.receiver?.room, "receiverAssignedEmployeeId": oldModel.receiver.userId, "receiverMachineStatusId": oldModel.receiver.status.id ?? "", "receiverComment": oldModel.receiver.comment, @@ -225,8 +228,11 @@ class DeviceTransferProvider extends ChangeNotifier { "senderEndDate": oldModel.sender.timer?.endAt?.toIso8601String(), "senderTravelingHours": oldModel.sender.travelingHours, "senderAttachmentName": oldModel.sender?.signature ?? "", - "destSiteId": newModel.client.id, - "destDepartmentId": newModel.department.id, + "destSiteId": newModel.client?.id, + "destDepartmentId": newModel.department?.id, + "destBuildingId": newModel.building?.id, + "destFloorId": newModel.floor?.id, + "destRoom": newModel.room, "receiverAssignedEmployeeId": newModel.userId, "receiverMachineStatusId": newModel.status?.id ?? "", "receiverComment": newModel.comment, @@ -237,7 +243,7 @@ class DeviceTransferProvider extends ChangeNotifier { "receiverAttachmentName": newModel?.signature ?? "", }); } - + if (true) {} //body.addAll(newModel.toJson(isSender)); print(body); Response response; diff --git a/lib/models/device/device_transfer_info.dart b/lib/models/device/device_transfer_info.dart index dd96f298..3a645508 100644 --- a/lib/models/device/device_transfer_info.dart +++ b/lib/models/device/device_transfer_info.dart @@ -9,6 +9,9 @@ class DeviceTransferInfo { String comment; Hospital client; Department department; + Buildings building; + Floors floor; + String room; String workingHours; // DateTime startDate; @@ -34,6 +37,9 @@ class DeviceTransferInfo { this.status, this.assignedEmployeeName, this.timer, + this.building, + this.room, + this.floor, }); Map toJson(bool isSender) { @@ -63,6 +69,19 @@ class DeviceTransferInfo { userName = old.userName; client = Hospital.fromHospital(old.client); department = Department.fromDepartment(old.department); + building = Buildings( + id: old.building?.id, + name: old.building?.name, + value: old.building?.value, + floors: old.building?.floors, + ); + floor = Floors( + id: old.floor?.id, + name: old.floor?.name, + value: old.floor?.value, + departments: old.floor?.departments, + ); + room = old.room; workingHours = old.workingHours; // startDate = old.startDate; // endDate = old.endDate; @@ -94,6 +113,15 @@ class DeviceTransferInfo { id: parsedJson["${key}DepartmentId"], name: parsedJson["${key}DepartmentName"], ), + building: Buildings( + id: parsedJson["${key}BuildingId"], + name: parsedJson["${key}BuildingName"], + ), + floor: Floors( + id: parsedJson["${key}FloorId"], + name: parsedJson["${key}FloorName"], + ), + room: parsedJson["${key}Room"], status: Lookup( id: parsedJson["${key}status"], name: parsedJson["${key}status"],