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.
64 lines
1.6 KiB
Dart
64 lines
1.6 KiB
Dart
import 'package:test_sa/models/lookup.dart';
|
|
|
|
class AssetTrackingSearchModel {
|
|
AssetTrackingSearchModel({
|
|
this.search,
|
|
this.tagStatus,
|
|
this.lastSeen,
|
|
this.tagAssignment,
|
|
this.types,
|
|
this.departments,
|
|
this.status,
|
|
this.startDate,
|
|
this.endDate,
|
|
});
|
|
|
|
String? search;
|
|
List<Lookup>? tagStatus;
|
|
List<Lookup>? lastSeen;
|
|
List<Lookup>? tagAssignment;
|
|
List<Lookup>? departments;
|
|
List<Lookup>? types;
|
|
List<Lookup>? status;
|
|
String? startDate, endDate;
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final map = <String, dynamic>{};
|
|
|
|
if (search != null && search!.trim().isNotEmpty) {
|
|
map['searchString'] = search!.trim();
|
|
}
|
|
|
|
if (tagStatus?.isNotEmpty == true) {
|
|
map['tagStatusIds'] = tagStatus!.map((e) => e.id).toList();
|
|
}
|
|
|
|
if (lastSeen?.isNotEmpty == true) {
|
|
map['lastSeenIds'] = lastSeen!.map((e) => e.id).toList();
|
|
}
|
|
|
|
if (tagAssignment?.isNotEmpty == true) {
|
|
map['tagAssignmentIds'] = tagAssignment!.map((e) => e.id).toList();
|
|
}
|
|
|
|
if (types?.isNotEmpty == true) {
|
|
map['typeIds'] = types!.map((e) => e.id).toList();
|
|
}
|
|
|
|
if (departments?.isNotEmpty == true) {
|
|
map['departmentIds'] = departments!.map((e) => e.id).toList();
|
|
}
|
|
|
|
if (status?.isNotEmpty == true) {
|
|
map['statusIds'] = status!.map((e) => e.id).toList();
|
|
}
|
|
if (startDate != null && startDate!.trim().isNotEmpty) {
|
|
map['lastSeenFrom'] = startDate!.trim();
|
|
}
|
|
if (endDate != null && endDate!.trim().isNotEmpty) {
|
|
map['lastSeenTo'] = endDate!.trim();
|
|
}
|
|
|
|
return map;
|
|
}
|
|
} |