Files
fcs/lib/domain/entities/pickup.dart

91 lines
2.1 KiB
Dart
Raw Normal View History

2021-09-14 11:03:03 +06:30
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/entities/package.dart';
class Pickup {
String? id;
DateTime? pickupDate;
String? fromTime;
String? toTime;
//for consignee
String? userID;
String? userName;
String? userPhoneNumber;
String? staffId;
String? staffName;
String? staffPhoneNumber;
//for shipper
String? fcsID;
String? shipperName;
String? shipperPhoneNumber;
String? status;
List<Package> packages;
Pickup(
{this.id,
this.userID,
this.userName,
this.userPhoneNumber,
this.staffId,
this.staffName,
this.staffPhoneNumber,
this.pickupDate,
this.fromTime,
this.toTime,
this.fcsID,
this.shipperName,
this.shipperPhoneNumber,
this.status,
this.packages = const []});
@override
bool operator ==(Object other) => other is Pickup && other.id == id;
@override
int get hashCode => id.hashCode;
bool isChangedForEdit(Pickup Pickup) {
return Pickup.userID != this.userID ||
Pickup.fcsID != this.fcsID ||
Pickup.packages != this.packages;
}
factory Pickup.fromMap(Map<String, dynamic> map, String id) {
var _pickupDate = (map['pickup_date'] as Timestamp);
return Pickup(
id: id,
pickupDate: _pickupDate.toDate(),
fromTime: map['from_time'],
toTime: map['to_time'],
staffId: map['staff_id'],
staffName: map['staff_name'],
staffPhoneNumber: map['staff_phone_number'],
userID: map['user_id'],
userName: map['user_name'],
userPhoneNumber: map['user_phone_number'],
status: map['status']);
}
Map<String, dynamic> toMap() {
return {
"id": id,
"pickup_date": pickupDate?.toUtc().toIso8601String(),
'from_time': fromTime,
'to_time': toTime,
'staff_id': staffId,
'staff_name': staffName,
"staff_phone_number": staffPhoneNumber,
'user_id': userID,
'user_name': userName,
'user_phone_number': userPhoneNumber,
'status': status,
};
}
@override
String toString() {
return 'Pickup{id: $id}';
}
}