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.
cloudsolutions-atoms/lib/models/new_models/assistant_employee.dart

57 lines
1.3 KiB
Dart

import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/new_models/assigned_employee.dart';
// int? id;
// String? userId;
// DateTime? startDate;
// DateTime? endDate;
// int? workingHours;
// String? technicalComment;
class AssistantEmployees extends Base {
String? userId;
DateTime? startDate;
DateTime? endDate;
int? workingHours;
String? technicalComment;
AssistantEmployees({
this.id,
this.user,
this.startDate,
this.technicalComment,
this.workingHours,
this.endDate,
this.userId,
}) : super(name: user?.name, identifier: user?.id);
AssistantEmployees.fromJson(dynamic json) {
id = json['id'];
user = json['user'] != null ? AssignedEmployee.fromJson(json['user']) : null;
name = user?.name;
userId = user?.id;
identifier = user?.id;
}
num? id; // Now nullable
AssignedEmployee? user; // Now nullable
AssistantEmployees copyWith({
num? id, // Parameter is now nullable
AssignedEmployee? user, // Parameter is now nullable
}) =>
AssistantEmployees(
id: id ?? this.id,
user: user ?? this.user,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
if (user != null) {
map['user'] = user?.toJson(); // Use '?.' to handle potential null
}
return map;
}
}