Fix building, floor, room issue when edit sender or receiver

main_design2.0
zaid_daoud 2 years ago
parent a26684de11
commit 3e314447c6

@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart';
@ -204,9 +205,9 @@ class DeviceTransferProvider extends ChangeNotifier {
"senderAttachmentName": newModel?.signature ?? "",
"destSiteId": oldModel.receiver.client?.id,
"destDepartmentId": oldModel.receiver.department?.id,
"destBuildingId": oldModel.receiver.building?.id,
"destFloorId": oldModel.receiver.floor?.id,
"destRoom": oldModel.receiver?.room,
"destBuildingId": oldModel.device?.destBuildingId,
"destFloorId": oldModel.device?.destFloorId,
"destRoom": oldModel.device?.destRoom,
"receiverAssignedEmployeeId": oldModel.receiver.userId,
"receiverMachineStatusId": oldModel.receiver.status.id ?? "",
"receiverComment": oldModel.receiver.comment,
@ -230,9 +231,9 @@ class DeviceTransferProvider extends ChangeNotifier {
"senderAttachmentName": oldModel.sender?.signature ?? "",
"destSiteId": newModel.client?.id,
"destDepartmentId": newModel.department?.id,
"destBuildingId": newModel.building?.id,
"destFloorId": newModel.floor?.id,
"destRoom": newModel.room,
"destBuildingId": oldModel.device?.destBuildingId,
"destFloorId": oldModel.device?.destFloorId,
"destRoom": oldModel.device?.destRoom,
"receiverAssignedEmployeeId": newModel.userId,
"receiverMachineStatusId": newModel.status?.id ?? "",
"receiverComment": newModel.comment,
@ -245,7 +246,7 @@ class DeviceTransferProvider extends ChangeNotifier {
}
if (true) {}
//body.addAll(newModel.toJson(isSender));
print(body);
log(body?.toString());
Response response;
try {
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: body);

@ -56,8 +56,11 @@ class DeviceTransfer {
number: parsedJson["assetNumber"],
assetName: parsedJson["assetName"],
serialNumber: parsedJson["assetSerialNo"],
destBuildingId: parsedJson["destBuildingId"],
destBuildingName: parsedJson["destBuildingName"],
destDepartmentId: parsedJson["destDepartmentId"],
destDepartmentName: parsedJson["destDepartmentName"],
destFloorId: parsedJson["destFloorId"],
destFloor: parsedJson["destFloorName"],
destRoom: parsedJson["destRoom"],
destSiteName: parsedJson["destSiteName"],

@ -9,9 +9,6 @@ class DeviceTransferInfo {
String comment;
Hospital client;
Department department;
Buildings building;
Floors floor;
String room;
String workingHours;
// DateTime startDate;
@ -37,9 +34,6 @@ class DeviceTransferInfo {
this.status,
this.assignedEmployeeName,
this.timer,
this.building,
this.room,
this.floor,
});
Map<String, String> toJson(bool isSender) {
@ -69,19 +63,6 @@ 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;
@ -113,19 +94,6 @@ 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"],
),
);
}
}

@ -144,13 +144,15 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
ASmallButton(
text: _subtitle.edit,
onPressed: (_isSender)
? ( _model.sender.status?.name=="Closed" ? null: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: true,
)));
})
? (_model.sender.status?.name == "Closed"
? null
: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: true,
)));
})
: null,
),
],
@ -170,13 +172,15 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
ASmallButton(
text: _subtitle.edit,
onPressed: (_isReceiver)
? ( _model.receiver.status?.name=="Closed" ? null: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: false,
)));
})
? (_model.receiver.status?.name == "Closed"
? null
: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: false,
)));
})
: null,
),
],

Loading…
Cancel
Save