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/new_models/site.dart

46 lines
1.1 KiB
Dart

import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/new_models/building.dart';
class Site extends Base {
Site({
this.id,
this.custName,
this.buildings,
}) : super(identifier: id.toString(), name: custName);
Site.fromJson(dynamic json) {
id = json['id'];
identifier = id.toString();
custName = json['custName'];
name = custName;
if (json['buildings'] != null) {
buildings = [];
json['buildings'].forEach((v) {
buildings.add(Building.fromJson(v));
});
}
}
num id;
String custName;
List<Building> buildings;
Site copyWith({
num id,
String custName,
List<Building> buildings,
}) =>
Site(
id: id ?? this.id,
custName: custName ?? this.custName,
buildings: buildings ?? this.buildings,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['custName'] = custName;
if (buildings != null) {
map['buildings'] = buildings.map((v) => v.toJson()).toList();
}
return map;
}
}