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/visits/visits_search.dart

88 lines
2.1 KiB
Dart

3 years ago
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
3 years ago
class VisitsSearch{
String deviceSerialNumber;
3 years ago
Hospital hospital;
3 years ago
String brand;
3 years ago
Lookup model;
Lookup contactStatus;
3 years ago
DateTime expectedDateFrom;
DateTime expectedDateTo;
DateTime actualDateFrom;
DateTime actualDateTo;
3 years ago
Lookup statusValue;
3 years ago
VisitsSearch({
this.deviceSerialNumber,
this.statusValue,
this.brand,
3 years ago
this.hospital,
3 years ago
this.actualDateTo,
this.actualDateFrom,
this.model,
this.contactStatus,
this.expectedDateFrom,
this.expectedDateTo,
});
fromSearch(VisitsSearch newSearch){
deviceSerialNumber = newSearch.deviceSerialNumber;
brand = newSearch.brand;
3 years ago
hospital = newSearch.hospital;
3 years ago
actualDateTo = newSearch.actualDateTo;
actualDateFrom = newSearch.actualDateFrom;
model = newSearch.model;
contactStatus = newSearch.contactStatus;
expectedDateFrom = newSearch.expectedDateFrom;
expectedDateTo = newSearch.expectedDateTo;
statusValue = newSearch.statusValue;
}
3 years ago
Map<String,dynamic> toMap(){
Map<String,dynamic> _search = {};
3 years ago
if(deviceSerialNumber != null && deviceSerialNumber.isNotEmpty){
3 years ago
_search["assetId"]= deviceSerialNumber;
3 years ago
}
3 years ago
if(hospital != null){
_search["siteId"]= hospital.id;
3 years ago
}
if(brand != null && brand.isNotEmpty){
3 years ago
// todo get new key
_search[""]= brand;
3 years ago
}
3 years ago
if(model != null){
_search["modelId"]= model.id;
3 years ago
}
if(expectedDateFrom != null){
3 years ago
_search["expectedDateFrom"]= expectedDateFrom.toIso8601String();
3 years ago
}
if(expectedDateTo != null){
3 years ago
_search["expectedDateTo"]= expectedDateTo.toIso8601String();
3 years ago
}
if(actualDateFrom != null){
3 years ago
_search["actualDateFrom"]= actualDateFrom.toIso8601String();
3 years ago
}
if(actualDateTo != null){
3 years ago
_search["actualDateTo"]= actualDateTo.toIso8601String();
3 years ago
}
if(statusValue != null){
3 years ago
_search["visitStatusId"]= statusValue.id;
3 years ago
}
if(contactStatus != null){
3 years ago
_search["assignedToId"]= contactStatus.id;
3 years ago
}
return _search;
}
}