From 1381d54208c0126bf2e78c35c286d905850ee9b2 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Sun, 11 Jun 2023 13:54:21 +0300 Subject: [PATCH] Create Gas Refill Bug Fixed --- .../providers/api/gas_refill_provider.dart | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index 36c39c27..e5c0fadd 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -91,22 +91,23 @@ class GasRefillProvider extends ChangeNotifier { @required User user, @required GasRefillModel model, }) async { + print("ss"); Map body = { "uid": user.id.toString(), "token": user.token ?? "", "building": {"id": building?.id, "name": building?.name, "value": building?.value}, - "floor": {"id": floor.id, "name": floor.name, "value": floor.value}, - if (expectedDateTime != null) "expectedDate": expectedDateTime, - if (expectedDateTime != null) "expectedTime": expectedDateTime, - if (startDate != null) "startDate": startDate, - if (startDate != null) "startTime": startDate, - if (endDate != null) "endDate": endDate, - if (endDate != null) "endTime": endDate, - "department": {"id": department.id, "departmentName": department.name, "departmentCode": "", "ntCode": ""}, + "floor": {"id": floor?.id, "name": floor?.name, "value": floor?.value}, + if (expectedDateTime != null) "expectedDate": expectedDateTime?.toIso8601String(), + if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(), + if (startDate != null) "startDate": startDate?.toIso8601String(), + if (startDate != null) "startTime": startDate?.toIso8601String(), + if (endDate != null) "endDate": endDate?.toIso8601String(), + if (endDate != null) "endTime": endDate?.toIso8601String(), + "department": {"id": department?.id, "departmentName": department?.name, "departmentCode": "", "ntCode": ""}, "GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}", "status": model.status.toMap(), }; - + print("ss1"); body["gazRefillDetails"] = model.details .map((model) => { "gasType": model.type.toMap(), @@ -119,6 +120,7 @@ class GasRefillProvider extends ChangeNotifier { Response response; try { response = await ApiManager.instance.post(URLs.requestGasRefill, body: body); + print("ss2"); stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { if (items != null) { @@ -128,6 +130,7 @@ class GasRefillProvider extends ChangeNotifier { } return response.statusCode; } catch (error) { + print(error); return -1; } }