118 lines
3.4 KiB
Dart
118 lines
3.4 KiB
Dart
import '../core/utils/safe_convert.dart';
|
|
|
|
class NamedRecord {
|
|
final int id;
|
|
final String name;
|
|
|
|
const NamedRecord({required this.id, required this.name});
|
|
|
|
factory NamedRecord.fromJson(Map<String, dynamic> json) {
|
|
return NamedRecord(
|
|
id: SafeConvert.toSafeInt(json['id']),
|
|
name: SafeConvert.toSafeString(json['name']),
|
|
);
|
|
}
|
|
|
|
static NamedRecord? fromNullableJson(dynamic json) {
|
|
final map = SafeConvert.toNullableMap(json);
|
|
if (map == null) return null;
|
|
return NamedRecord.fromJson(map);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {'id': id, 'name': name};
|
|
|
|
@override
|
|
String toString() => name;
|
|
}
|
|
|
|
class StudentBasic {
|
|
final int id;
|
|
final String name;
|
|
|
|
const StudentBasic({required this.id, required this.name});
|
|
|
|
factory StudentBasic.fromJson(Map<String, dynamic> json) {
|
|
return StudentBasic(
|
|
id: SafeConvert.toSafeInt(json['id']),
|
|
name: SafeConvert.toSafeString(json['name']),
|
|
);
|
|
}
|
|
|
|
static StudentBasic? fromNullableJson(dynamic json) {
|
|
final map = SafeConvert.toNullableMap(json);
|
|
if (map == null) return null;
|
|
return StudentBasic.fromJson(map);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {'id': id, 'name': name};
|
|
}
|
|
|
|
class StudentProfile {
|
|
final int id;
|
|
final String studentId;
|
|
final String admissionNumber;
|
|
final String? rollNumber;
|
|
final String fullName;
|
|
final String? email;
|
|
final String? mobile;
|
|
final String? gender;
|
|
final String? dateOfBirth;
|
|
final String status;
|
|
|
|
final NamedRecord? campus;
|
|
final NamedRecord? department;
|
|
final NamedRecord? program;
|
|
final NamedRecord? level;
|
|
final NamedRecord? academicYear;
|
|
final NamedRecord? academicTerm;
|
|
final NamedRecord? batch;
|
|
final NamedRecord? semester;
|
|
final NamedRecord? section;
|
|
|
|
const StudentProfile({
|
|
required this.id,
|
|
required this.studentId,
|
|
required this.admissionNumber,
|
|
this.rollNumber,
|
|
required this.fullName,
|
|
this.email,
|
|
this.mobile,
|
|
this.gender,
|
|
this.dateOfBirth,
|
|
required this.status,
|
|
this.campus,
|
|
this.department,
|
|
this.program,
|
|
this.level,
|
|
this.academicYear,
|
|
this.academicTerm,
|
|
this.batch,
|
|
this.semester,
|
|
this.section,
|
|
});
|
|
|
|
factory StudentProfile.fromJson(Map<String, dynamic> json) {
|
|
return StudentProfile(
|
|
id: SafeConvert.toSafeInt(json['id']),
|
|
studentId: SafeConvert.toSafeString(json['student_id']),
|
|
admissionNumber: SafeConvert.toSafeString(json['admission_number']),
|
|
rollNumber: SafeConvert.toNullableString(json['roll_number']),
|
|
fullName: SafeConvert.toSafeString(json['full_name']),
|
|
email: SafeConvert.toNullableString(json['email']),
|
|
mobile: SafeConvert.toNullableString(json['mobile']),
|
|
gender: SafeConvert.toNullableString(json['gender']),
|
|
dateOfBirth: SafeConvert.toNullableString(json['date_of_birth']),
|
|
status: SafeConvert.toSafeString(json['status'], 'draft'),
|
|
campus: NamedRecord.fromNullableJson(json['campus']),
|
|
department: NamedRecord.fromNullableJson(json['department']),
|
|
program: NamedRecord.fromNullableJson(json['program']),
|
|
level: NamedRecord.fromNullableJson(json['level']),
|
|
academicYear: NamedRecord.fromNullableJson(json['academic_year']),
|
|
academicTerm: NamedRecord.fromNullableJson(json['academic_term']),
|
|
batch: NamedRecord.fromNullableJson(json['batch']),
|
|
semester: NamedRecord.fromNullableJson(json['semester']),
|
|
section: NamedRecord.fromNullableJson(json['section']),
|
|
);
|
|
}
|
|
}
|