You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.4 KiB
84 lines
2.4 KiB
class TransferPetiModel { |
|
int? id; |
|
String? mobile_id; |
|
int? peti_id; |
|
int? name_customer; |
|
int? source_warehouse; |
|
int? destination_warehouse; |
|
DateTime? date; |
|
|
|
String? created_by; |
|
String? updated_by; |
|
|
|
DateTime? created_at; |
|
DateTime? updated_at; |
|
DateTime? deleted_at; |
|
|
|
TransferPetiModel({ |
|
this.id, |
|
this.mobile_id, |
|
this.peti_id, |
|
this.name_customer, |
|
this.source_warehouse, |
|
this.destination_warehouse, |
|
this.date, |
|
this.created_by, |
|
this.updated_by, |
|
this.created_at, |
|
this.updated_at, |
|
this.deleted_at, |
|
}); |
|
|
|
factory TransferPetiModel.fromJson(Map<String, dynamic> json) { |
|
return TransferPetiModel( |
|
id: json['id'], |
|
mobile_id: json['mobile_id'] != null ? json['mobile_id'] : null, |
|
peti_id: json['peti_id'] != null |
|
? int.parse(json['peti_id'].toString()) |
|
: null, |
|
name_customer: json['name_customer'] != null |
|
? int.parse(json['name_customer'].toString()) |
|
: null, |
|
source_warehouse: json['source_warehouse'] != null |
|
? int.parse(json['source_warehouse'].toString()) |
|
: null, |
|
destination_warehouse: json['destination_warehouse'] != null |
|
? int.parse(json['destination_warehouse'].toString()) |
|
: null, |
|
date: parseDateTime(json['date']), |
|
created_by: json['created_by'] != null ? json['created_by'] : null, |
|
updated_by: json['updated_by'] != null ? json['updated_by'] : null, |
|
created_at: parseDateTime(json['created_at']), |
|
updated_at: parseDateTime(json['updated_at']), |
|
deleted_at: parseDateTime(json['deleted_at']), |
|
); |
|
} |
|
|
|
Map<String, dynamic> toJson() { |
|
return { |
|
'id': id, |
|
'mobile_id': mobile_id, |
|
'peti_id': peti_id, |
|
'name_customer': name_customer, |
|
'source_warehouse': source_warehouse, |
|
'destination_warehouse': destination_warehouse, |
|
'date': date?.toIso8601String(), |
|
'created_by': created_by, |
|
'updated_by': updated_by, |
|
'created_at': created_at?.toIso8601String(), |
|
'updated_at': updated_at?.toIso8601String(), |
|
'deleted_at': deleted_at?.toIso8601String(), |
|
}; |
|
} |
|
|
|
static DateTime? parseDateTime(String? dateTimeString) { |
|
if (dateTimeString != null && dateTimeString.isNotEmpty) { |
|
try { |
|
return DateTime.parse(dateTimeString); |
|
} catch (e) { |
|
print('Error parsing DateTime: $e'); |
|
} |
|
} |
|
return null; |
|
} |
|
}
|
|
|