marco.pms.mobileapp/lib/model/employee_model.dart

49 lines
1.3 KiB
Dart

class EmployeeModel {
final String id;
final String employeeId;
final String name;
final String designation;
final String checkIn;
final String checkOut;
final int activity;
int action;
EmployeeModel({
required this.id,
required this.employeeId,
required this.name,
required this.designation,
required this.checkIn,
required this.checkOut,
required this.activity,
required this.action,
});
factory EmployeeModel.fromJson(Map<String, dynamic> json) {
return EmployeeModel(
id: json['id']?.toString() ?? '',
employeeId: json['employeeId']?.toString() ?? '',
name: '${json['firstName'] ?? ''} ${json['lastName'] ?? ''}'.trim(),
designation: json['jobRoleName'] ?? '',
checkIn: json['checkIn']?.toString() ?? '-',
checkOut: json['checkOut']?.toString() ?? '-',
action: json['action'] ?? 0,
activity: json['activity'] ?? 0,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'employeeId': employeeId,
'firstName': name.split(' ').first,
'lastName': name.split(' ').length > 1 ? name.split(' ').last : '',
'jobRoleName': designation,
'checkIn': checkIn,
'checkOut': checkOut,
'action': action,
'activity': activity,
};
}
}