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/gas_refill/gas_refill_model.dart

53 lines
1.4 KiB
Dart

2 years ago
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/lookup.dart';
2 years ago
class GasRefillModel {
2 years ago
int id;
//String userId;
2 years ago
String clientName;
String title;
Lookup status;
2 years ago
List<GasRefillDetails> details;
GasRefillModel({
this.id,
2 years ago
//this.userId,
2 years ago
this.clientName,
this.title,
this.status,
this.details,
});
bool validate() {
if (title == null) return false;
if (status == null) return false;
if (details == null && details.isEmpty) return false;
2 years ago
return true;
}
fromGasRefillModel(GasRefillModel model) {
2 years ago
id = model.id;
2 years ago
//userId = model.userId;
2 years ago
clientName = model.clientName;
title = model.title;
status = Lookup.fromStatus(model.status);
2 years ago
details = model.details.map((e) => GasRefillDetails.fromDetails(e)).toList();
}
factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) {
2 years ago
List<GasRefillDetails> details = [];
if (parsedJson["gazRefillDetails"] != null) {
2 years ago
List list = parsedJson["gazRefillDetails"];
2 years ago
details = list.map((e) => GasRefillDetails.fromJson(e)).toList();
}
return GasRefillModel(
id: parsedJson["id"],
2 years ago
//userId: parsedJson["uid"],
title: parsedJson["gazRefillNo"],
clientName: parsedJson["site"] == null ? null : parsedJson["site"]["custName"],
status: Lookup.fromJson(parsedJson["status"]),
2 years ago
details: details,
);
}
}