107 lines
2.6 KiB
Dart
107 lines
2.6 KiB
Dart
import '../model/local/live_tmp/livestock_local_model.dart';
|
|
import '../model/response/live_tmp/livestock_model.dart';
|
|
|
|
// Extension for LivestockData to convert to LivestockLocalModel
|
|
extension LivestockDataX on LivestockData {
|
|
LivestockLocalModel toLocal() {
|
|
return LivestockLocalModel()
|
|
..rancher = rancher?.toLocal()
|
|
..herd = herd?.toLocal()
|
|
..livestock = livestock?.map((e) => e.toLocal()).toList();
|
|
}
|
|
}
|
|
|
|
// Extension for LivestockLocalModel to convert to LivestockData
|
|
extension LivestockLocalModelX on LivestockLocalModel {
|
|
LivestockData toData() {
|
|
return LivestockData(
|
|
rancher: rancher?.toData(),
|
|
herd: herd?.toData(),
|
|
livestock: livestock?.map((e) => e.toData()).toList(),
|
|
);
|
|
}
|
|
}
|
|
|
|
// Extension for Rancher to convert to RancherLocal
|
|
extension RancherX on Rancher {
|
|
RancherLocal toLocal() {
|
|
return RancherLocal()
|
|
..name = name
|
|
..phone = phone
|
|
..image = image;
|
|
}
|
|
}
|
|
|
|
// Extension for RancherLocal to convert to Rancher
|
|
extension RancherLocalX on RancherLocal {
|
|
Rancher toData() {
|
|
return Rancher(name: name, phone: phone, image: image);
|
|
}
|
|
}
|
|
|
|
// Extension for Herd to convert to HerdLocal
|
|
extension HerdX on Herd {
|
|
HerdLocal toLocal() {
|
|
return HerdLocal()
|
|
..location = location?.toLocal()
|
|
..address = address
|
|
..image = image;
|
|
}
|
|
}
|
|
|
|
// Extension for HerdLocal to convert to Herd
|
|
extension HerdLocalX on HerdLocal {
|
|
Herd toData() {
|
|
return Herd(location: location?.toData(), address: address, image: image);
|
|
}
|
|
}
|
|
|
|
// Extension for Location to convert to LocationLocal
|
|
extension LocationX on Location {
|
|
LocationLocal toLocal() {
|
|
return LocationLocal()
|
|
..lat = lat
|
|
..lng = lng;
|
|
}
|
|
}
|
|
|
|
// Extension for LocationLocal to convert to Location
|
|
extension LocationLocalX on LocationLocal {
|
|
Location toData() {
|
|
return Location(lat: lat, lng: lng);
|
|
}
|
|
}
|
|
|
|
// Extension for Livestock to convert to LivestockLocal
|
|
extension LivestockX on Livestock {
|
|
LivestockLocal toLocal() {
|
|
return LivestockLocal()
|
|
..species = species
|
|
..breed = breed
|
|
..dateOfBirth = dateOfBirth
|
|
..sex = sex
|
|
..motherTag = motherTag
|
|
..fatherTag = fatherTag
|
|
..tagNumber = tagNumber
|
|
..tagType = tagType
|
|
..image = image;
|
|
}
|
|
}
|
|
|
|
// Extension for LivestockLocal to convert to Livestock
|
|
extension LivestockLocalX on LivestockLocal {
|
|
Livestock toData() {
|
|
return Livestock(
|
|
species: species,
|
|
breed: breed,
|
|
dateOfBirth: dateOfBirth,
|
|
sex: sex,
|
|
motherTag: motherTag,
|
|
fatherTag: fatherTag,
|
|
tagNumber: tagNumber,
|
|
tagType: tagType,
|
|
image: image,
|
|
);
|
|
}
|
|
}
|