Create Gas Refill Bug Fixed

pull/2/head
zaid_daoud 2 years ago
parent 83bf02e69f
commit 1381d54208

@ -91,22 +91,23 @@ class GasRefillProvider extends ChangeNotifier {
@required User user,
@required GasRefillModel model,
}) async {
print("ss");
Map<String, dynamic> 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;
}
}

Loading…
Cancel
Save