-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from B3-3iL-DLW/feat/marks-absences
Feat/marks absences
- Loading branch information
Showing
29 changed files
with
606 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:/Users/Jules/fvm/versions/3.19.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.19.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:/Users/Jules/fvm/versions/3.19.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,4 @@ flutter { | |
} | ||
|
||
dependencies { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
frontend/app_student/lib/api/account/repositories/account_repository.dart
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
frontend/app_student/lib/api/documents/entities/document_entity.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:io'; | ||
|
||
class DocumentEntity { | ||
final String title; | ||
final File? file; | ||
|
||
DocumentEntity({required this.title, required this.file}); | ||
|
||
Map<String, dynamic> toJson() => { | ||
'title': title, | ||
'file': file!.path, | ||
}; | ||
|
||
factory DocumentEntity.fromJson(Map<String, dynamic> json) { | ||
return DocumentEntity( | ||
title: json['title'], | ||
file: File(json['file']), | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
frontend/app_student/lib/api/documents/models/document_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:io'; | ||
import 'package:app_student/api/documents/entities/document_entity.dart'; | ||
|
||
class DocumentModel { | ||
final DocumentEntity entity; | ||
|
||
DocumentModel({required this.entity}); | ||
|
||
String get title => entity.title; | ||
|
||
File? get file => entity.file; | ||
|
||
factory DocumentModel.fromEntity(DocumentEntity entity) { | ||
return DocumentModel( | ||
entity: entity, | ||
); | ||
} | ||
|
||
DocumentEntity toEntity() { | ||
return DocumentEntity( | ||
title: title, | ||
file: file, | ||
); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'DocumentModel: {title: $title, file: ${file?.path}}'; | ||
} | ||
} |
46 changes: 33 additions & 13 deletions
46
frontend/app_student/lib/api/users/entities/user_entity.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
import 'dart:io'; | ||
import '../../documents/entities/document_entity.dart'; | ||
|
||
class UserEntity { | ||
final String? ine; | ||
final String firstName; | ||
final DateTime? birthDate; | ||
final String? className; | ||
final int? studentId; | ||
final File? marksFile; | ||
final File? absencesFile; | ||
String? ine; | ||
String? firstName; | ||
DateTime? birthDate; | ||
String? className; | ||
int? studentId; | ||
List<DocumentEntity>? documents; | ||
|
||
UserEntity( | ||
{required this.ine, | ||
required this.firstName, | ||
required this.birthDate, | ||
{this.ine, | ||
this.firstName, | ||
this.birthDate, | ||
this.className, | ||
this.studentId, | ||
this.marksFile, | ||
this.absencesFile}); | ||
this.documents}); | ||
|
||
Map<String, dynamic> toJson() => { | ||
'firstName': firstName, | ||
'className': className, | ||
'ine': ine, | ||
'birthDate': birthDate?.toIso8601String(), | ||
'studentId': studentId, | ||
'documents': documents?.map((doc) => doc.toJson()).toList(), | ||
}; | ||
|
||
factory UserEntity.fromJson(Map<String, dynamic> json) => UserEntity( | ||
firstName: json['firstName'], | ||
className: json['className'], | ||
ine: json['ine'], | ||
birthDate: json['birthDate'] != null | ||
? DateTime.parse(json['birthDate']) | ||
: null, | ||
studentId: json['studentId'], | ||
documents: (json['documents'] as List<dynamic>?) | ||
?.map((doc) => DocumentEntity.fromJson(doc)) | ||
.toList(), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,93 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:app_student/api/documents/models/document_model.dart'; | ||
import 'package:app_student/api/users/entities/user_entity.dart'; | ||
|
||
class UserModel { | ||
final UserEntity entity; | ||
UserEntity entity; | ||
|
||
UserModel({required this.entity}); | ||
|
||
String get firstName => entity.firstName; | ||
String? get firstName => entity.firstName; | ||
|
||
String get name => entity.firstName; | ||
set firstName(String? value) => entity.firstName = value; | ||
|
||
DateTime? get birthDate => entity.birthDate; | ||
|
||
set birthDate(DateTime? value) => entity.birthDate = value; | ||
|
||
String? get className => entity.className; | ||
|
||
set className(String? value) => entity.className = value; | ||
|
||
String? get ine => entity.ine; | ||
|
||
set ine(String? value) => entity.ine = value; | ||
|
||
int? get studentId => entity.studentId; | ||
|
||
File? get marksFile => entity.marksFile; | ||
set studentId(int? value) => entity.studentId = value; | ||
|
||
List<DocumentModel>? get documents => entity.documents | ||
?.map((documentEntity) => DocumentModel.fromEntity(documentEntity)) | ||
.toList(); | ||
|
||
set documents(List<DocumentModel>? value) { | ||
entity.documents = value?.map((model) => model.toEntity()).toList(); | ||
} | ||
|
||
Map<String, dynamic> toJson() => { | ||
'entity': entity.toJson(), | ||
}; | ||
|
||
factory UserModel.fromJson(Map<String, dynamic> json) => UserModel( | ||
entity: json['entity'] != null | ||
? UserEntity.fromJson(json['entity']) | ||
: UserEntity(), | ||
); | ||
|
||
@override | ||
String toString() { | ||
return 'User : {firstName: $firstName, birthDate: $birthDate, className: $className, ine: $ine, studentId: $studentId, documents: ${documents?.map((doc) => doc.toString()).join(', ')}}'; | ||
} | ||
|
||
bool get isEmpty { | ||
return firstName == null || firstName!.isEmpty; | ||
} | ||
|
||
bool get hasFirstName { | ||
return firstName != null && firstName!.isNotEmpty; | ||
} | ||
|
||
bool get hasBirthDate { | ||
return birthDate != null; | ||
} | ||
|
||
bool get hasClassName { | ||
return className != null && className!.isNotEmpty; | ||
} | ||
|
||
bool get hasIne { | ||
return ine != null && ine!.isNotEmpty; | ||
} | ||
|
||
bool get hasStudentId { | ||
return studentId != null; | ||
} | ||
|
||
bool get hasDocuments { | ||
return documents != null && documents!.isNotEmpty; | ||
} | ||
|
||
File? get absencesFile => entity.absencesFile; | ||
static UserModel create(String firstName, String? className, String? ine, | ||
DateTime? birthDate, int? studentId, List<DocumentModel>? documents) { | ||
return UserModel( | ||
entity: UserEntity( | ||
firstName: firstName, | ||
className: className, | ||
ine: ine, | ||
birthDate: birthDate, | ||
studentId: studentId, | ||
documents: documents?.map((doc) => doc.toEntity()).toList(), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.