58 lines
1.6 KiB
Dart
58 lines
1.6 KiB
Dart
class AttendanceLogModel {
|
|
final String id;
|
|
final String employeeId;
|
|
final String name;
|
|
final String role;
|
|
final DateTime? checkIn;
|
|
final DateTime? checkOut;
|
|
final int activity;
|
|
final String firstName;
|
|
final String lastName;
|
|
final String designation;
|
|
|
|
AttendanceLogModel({
|
|
required this.id,
|
|
required this.employeeId,
|
|
required this.name,
|
|
required this.role,
|
|
this.checkIn,
|
|
this.checkOut,
|
|
required this.activity,
|
|
required this.firstName,
|
|
required this.lastName,
|
|
required this.designation,
|
|
});
|
|
|
|
factory AttendanceLogModel.fromJson(Map<String, dynamic> json) {
|
|
return AttendanceLogModel(
|
|
id: json['id']?.toString() ?? '',
|
|
employeeId: json['employeeId']?.toString() ?? '',
|
|
name: '${json['firstName'] ?? ''} ${json['lastName'] ?? ''}'.trim(),
|
|
role: json['jobRoleName'] ?? '',
|
|
checkIn: json['checkInTime'] != null
|
|
? DateTime.tryParse(json['checkInTime'])
|
|
: null,
|
|
checkOut: json['checkOutTime'] != null
|
|
? DateTime.tryParse(json['checkOutTime'])
|
|
: null,
|
|
activity: json['activity'] ?? 0,
|
|
firstName: json['firstName'] ?? '',
|
|
lastName: json['lastName'] ?? '',
|
|
designation: json['jobRoleName'] ?? '',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'employeeId': employeeId,
|
|
'firstName': name.split(' ').first,
|
|
'lastName': name.split(' ').length > 1 ? name.split(' ').last : '',
|
|
'jobRoleName': role,
|
|
'checkInTime': checkIn?.toIso8601String(),
|
|
'checkOutTime': checkOut?.toIso8601String(),
|
|
'activity': activity,
|
|
};
|
|
}
|
|
}
|