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/hospital.dart

150 lines
3.7 KiB
Dart

class Hospital {
int id;
int customerCode;
String name;
List<Buildings> buildings;
Hospital({
this.id,
this.customerCode,
this.name,
this.buildings,
});
factory Hospital.fromJson(Map<String, dynamic> parsedJson) {
List<Buildings> buildings = [];
if (parsedJson['buildings'] != null) {
buildings = [];
parsedJson['buildings'].forEach((v) {
buildings.add(new Buildings.fromJson(v));
});
}
return Hospital(id: parsedJson["id"], name: parsedJson["custName"], customerCode: parsedJson["customerCode"], buildings: buildings);
}
factory Hospital.fromHospital(Hospital hospital) {
return Hospital(id: hospital?.id, name: hospital?.name, customerCode: hospital?.customerCode, buildings: hospital?.buildings);
}
Map<String, dynamic> toMap() {
return {'id': id, 'customerCode': customerCode, 'custName': name, "buildings": buildings};
}
}
// class Data {
// int id;
// int customerCode;
// String custName;
// List<Buildings> buildings;
//
// Data({this.id, this.customerCode, this.custName, this.buildings});
//
// Data.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// customerCode = json['customerCode'];
// custName = json['custName'];
// if (json['buildings'] != null) {
// buildings = new List<Buildings>();
// json['buildings'].forEach((v) {
// buildings.add(new Buildings.fromJson(v));
// });
// }
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['id'] = this.id;
// data['customerCode'] = this.customerCode;
// data['custName'] = this.custName;
// if (this.buildings != null) {
// data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
// }
// return data;
// }
// }
class Buildings {
int id;
String name;
int value;
List<Floors> floors;
Buildings({this.id, this.name, this.value, this.floors});
Buildings.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
if (json['floors'] != null) {
floors = new List<Floors>();
json['floors'].forEach((v) {
floors.add(new Floors.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
if (this.floors != null) {
data['floors'] = this.floors.map((v) => v.toJson()).toList();
}
return data;
}
}
class Floors {
int id;
String name;
int value;
List<Departments> departments;
Floors({this.id, this.name, this.value, this.departments});
Floors.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
value = json['value'];
if (json['departments'] != null) {
departments = new List<Departments>();
json['departments'].forEach((v) {
departments.add(new Departments.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['value'] = this.value;
if (this.departments != null) {
data['departments'] = this.departments.map((v) => v.toJson()).toList();
}
return data;
}
}
class Departments {
int id;
String name;
Departments({this.id, this.name});
Departments.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}