marco.pms.mobileapp/lib/model/global_project_model.dart

51 lines
1.2 KiB
Dart

class GlobalProjectModel {
final String id;
final String name;
final String projectAddress;
final String contactPerson;
final DateTime startDate;
final DateTime endDate;
final int teamSize;
final String projectStatusId;
final String? tenantId;
GlobalProjectModel({
required this.id,
required this.name,
required this.projectAddress,
required this.contactPerson,
required this.startDate,
required this.endDate,
required this.teamSize,
required this.projectStatusId,
this.tenantId,
});
factory GlobalProjectModel.fromJson(Map<String, dynamic> json) {
return GlobalProjectModel(
id: json['id'] ?? '',
name: json['name'] ?? '',
projectAddress: json['projectAddress'] ?? '',
contactPerson: json['contactPerson'] ?? '',
startDate: DateTime.parse(json['startDate']),
endDate: DateTime.parse(json['endDate']),
teamSize: json['teamSize'] ?? 0, // ✅ SAFER
projectStatusId: json['projectStatusId'] ?? '',
tenantId: json['tenantId'],
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'projectAddress': projectAddress,
'contactPerson': contactPerson,
'startDate': startDate.toIso8601String(),
'endDate': endDate.toIso8601String(),
'teamSize': teamSize,
'projectStatusId': projectStatusId,
'tenantId': tenantId,
};
}
}