You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/part.dart

37 lines
756 B
Dart

3 years ago
class Part{
3 years ago
int id;
3 years ago
int reportPartID;
3 years ago
String code;
String name;
int quantity;
Part({
this.id,
3 years ago
this.reportPartID,
3 years ago
this.code,
this.name,
this.quantity = 1,
});
3 years ago
Map<String,dynamic> toJson(){
return {
"id": reportPartID ?? 0,
"sparePart":{
"id":id,
"partNo": code,
"partName":name
},
"qty":quantity
};
}
factory Part.fromJson(Map<String,dynamic> parsedJson,{Map<String,dynamic> reportJson}){
3 years ago
return Part(
3 years ago
id: parsedJson["id"],
3 years ago
reportPartID: reportJson != null ? reportJson["id"] : null,
3 years ago
code: parsedJson["partNo"],
name: parsedJson["partName"],
3 years ago
quantity: reportJson != null ? (reportJson["qty"] ?? 1).toInt() : 1,
3 years ago
);
}
}