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.
107 lines
3.4 KiB
Dart
107 lines
3.4 KiB
Dart
class SiteRequestModel {
|
|
final String? id;
|
|
final String requestType; // Add Site, Change Site, Remove Site
|
|
final String employeeId;
|
|
final String fullName;
|
|
final String emailAddress;
|
|
final String mobileNumber;
|
|
final String? extensionNumber;
|
|
final List<String> siteIds;
|
|
final List<String> siteNames;
|
|
final List<String>? departmentIds;
|
|
final List<String>? departmentNames;
|
|
final String role;
|
|
final String status; // Pending, Approved, Rejected
|
|
final DateTime requestDate;
|
|
|
|
SiteRequestModel({
|
|
this.id,
|
|
required this.requestType,
|
|
required this.employeeId,
|
|
required this.fullName,
|
|
required this.emailAddress,
|
|
required this.mobileNumber,
|
|
this.extensionNumber,
|
|
required this.siteIds,
|
|
required this.siteNames,
|
|
this.departmentIds,
|
|
this.departmentNames,
|
|
required this.role,
|
|
required this.status,
|
|
required this.requestDate,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'requestType': requestType,
|
|
'employeeId': employeeId,
|
|
'fullName': fullName,
|
|
'emailAddress': emailAddress,
|
|
'mobileNumber': mobileNumber,
|
|
'extensionNumber': extensionNumber,
|
|
'siteIds': siteIds,
|
|
'siteNames': siteNames,
|
|
'departmentIds': departmentIds,
|
|
'departmentNames': departmentNames,
|
|
'role': role,
|
|
'status': status,
|
|
'requestDate': requestDate.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
factory SiteRequestModel.fromJson(Map<String, dynamic> json) {
|
|
return SiteRequestModel(
|
|
id: json['id'],
|
|
requestType: json['requestType'] ?? '',
|
|
employeeId: json['employeeId'] ?? '',
|
|
fullName: json['fullName'] ?? '',
|
|
emailAddress: json['emailAddress'] ?? '',
|
|
mobileNumber: json['mobileNumber'] ?? '',
|
|
extensionNumber: json['extensionNumber'],
|
|
siteIds: List<String>.from(json['siteIds'] ?? []),
|
|
siteNames: List<String>.from(json['siteNames'] ?? []),
|
|
departmentIds: json['departmentIds'] != null ? List<String>.from(json['departmentIds']) : null,
|
|
departmentNames: json['departmentNames'] != null ? List<String>.from(json['departmentNames']) : null,
|
|
role: json['role'] ?? '',
|
|
status: json['status'] ?? 'Pending',
|
|
requestDate: json['requestDate'] != null ? DateTime.parse(json['requestDate']) : DateTime.now(),
|
|
);
|
|
}
|
|
|
|
SiteRequestModel copyWith({
|
|
String? id,
|
|
String? requestType,
|
|
String? employeeId,
|
|
String? fullName,
|
|
String? emailAddress,
|
|
String? mobileNumber,
|
|
String? extensionNumber,
|
|
List<String>? siteIds,
|
|
List<String>? siteNames,
|
|
List<String>? departmentIds,
|
|
List<String>? departmentNames,
|
|
String? role,
|
|
String? status,
|
|
DateTime? requestDate,
|
|
}) {
|
|
return SiteRequestModel(
|
|
id: id ?? this.id,
|
|
requestType: requestType ?? this.requestType,
|
|
employeeId: employeeId ?? this.employeeId,
|
|
fullName: fullName ?? this.fullName,
|
|
emailAddress: emailAddress ?? this.emailAddress,
|
|
mobileNumber: mobileNumber ?? this.mobileNumber,
|
|
extensionNumber: extensionNumber ?? this.extensionNumber,
|
|
siteIds: siteIds ?? this.siteIds,
|
|
siteNames: siteNames ?? this.siteNames,
|
|
departmentIds: departmentIds ?? this.departmentIds,
|
|
departmentNames: departmentNames ?? this.departmentNames,
|
|
role: role ?? this.role,
|
|
status: status ?? this.status,
|
|
requestDate: requestDate ?? this.requestDate,
|
|
);
|
|
}
|
|
}
|
|
|