Commit fe7a2b72 authored by Almouhannad's avatar Almouhannad

(B) Edit collections implementation

parent 051a3ae6
......@@ -22,7 +22,11 @@ public sealed class Disease : Entity
#region Navigations
public ICollection<PatientDisease> Patients { get; set; } = [];
#region Patients
private readonly List<PatientDisease> _patients = [];
public IReadOnlyCollection<PatientDisease> Patients => _patients;
#endregion
#endregion
......
......@@ -34,7 +34,12 @@ public sealed class Medicine : Entity
#region Navigations
public ICollection<PatientMedicine> Patients { get; set; } = [];
#region Patients
private readonly List<PatientMedicine> _patients = [];
public IReadOnlyCollection<PatientMedicine> Patients => _patients;
#endregion
#endregion
......
......@@ -28,7 +28,11 @@ public sealed class Doctor : Entity
#region Navigations
public ICollection<DoctorPhone> Phones { get; set; } = [];
#region Phones
private readonly List<DoctorPhone> _phones = [];
public IReadOnlyCollection<DoctorPhone> Phones => _phones;
#endregion
#endregion
......@@ -66,10 +70,7 @@ public sealed class Doctor : Entity
throw;
}
if (Phones is null)
Phones = [];
Phones.Add(doctorPhone);
_phones.Add(doctorPhone);
}
#endregion
......
......@@ -42,11 +42,21 @@ public sealed class Employee : Entity
#region Navigations
public ICollection<EmployeeFamilyMember> FamilyMembers { get; set; } = [];
#region Family members
private readonly List<EmployeeFamilyMember> _familyMembers = [];
public IReadOnlyCollection<EmployeeFamilyMember> FamilyMembers => _familyMembers;
public ICollection<Employee> RelatedEmployees { get; set; } = [];
#endregion
#region Related employees
private readonly List<Employee> _relatedEmployees = [];
public IReadOnlyCollection<Employee> RelatedEmployees => _relatedEmployees;
private readonly List<Employee> _relatedTo = [];
public IReadOnlyCollection<Employee> RelatedTo => _relatedTo;
#endregion
public ICollection<Employee> RelatedTo { get; set; } = [];
#endregion
......@@ -115,26 +125,14 @@ public sealed class Employee : Entity
throw;
}
if (FamilyMembers is null)
FamilyMembers = [];
FamilyMembers.Add(employeeFamilyMember);
_familyMembers.Add(employeeFamilyMember);
}
#endregion
#region Add related employee
public void AddRelatedEmployee( Employee employee )
public void AddRelatedEmployee(Employee employee)
{
// Add new employee to related
if (RelatedEmployees is null)
RelatedEmployees = [];
RelatedEmployees.Add(employee);
// Make this related to new employee
if (employee.RelatedTo is null)
employee.RelatedTo = [];
employee.RelatedTo.Add(this);
_relatedEmployees.Add(employee);
}
#endregion
......
......@@ -22,10 +22,6 @@ public sealed class Patient : Entity
PersonalInfo = personalInfo;
DateOfBirth = dateOfBirth;
Gender = gender;
Diseases = [];
Medicines = [];
Visits = [];
}
#endregion
......@@ -54,11 +50,23 @@ public sealed class Patient : Entity
#region Navigations
public ICollection<PatientDisease> Diseases { get; set; }
#region Diseases
private readonly List<PatientDisease> _diseases = [];
public IReadOnlyCollection<PatientDisease> Diseases => _diseases;
#endregion
#region Medicines
private readonly List<PatientMedicine> _medicines = [];
public IReadOnlyCollection<PatientMedicine> Medicines => _medicines;
#endregion
public ICollection<PatientMedicine> Medicines { get; set; }
#region Visits
private readonly List<Visit> _visits = [];
public IReadOnlyCollection<Visit> Visits => _visits;
public ICollection<Visit> Visits { get; set; }
#endregion
#endregion
......@@ -122,9 +130,8 @@ public sealed class Patient : Entity
{
throw;
}
if (Medicines is null)
Medicines = [];
Medicines.Add(entry);
_medicines.Add(entry);
}
#endregion
......@@ -141,11 +148,7 @@ public sealed class Patient : Entity
throw;
}
if (Diseases is null)
Diseases = [];
Diseases.Add(entry);
_diseases.Add(entry);
}
#endregion
......
......@@ -63,9 +63,23 @@ public sealed class Visit : Entity
#region Navigations
public ICollection<VisitMedicalImage> MedicalImages { get; set; } = [];
public ICollection<VisitMedicalTest> MedicalTests { get; set; } = [];
public ICollection<VisitMedicine> Medicines { get; set; } = [];
#region Medical images
private readonly List<VisitMedicalImage> _medicalImages = [];
public IReadOnlyCollection<VisitMedicalImage> MedicalImages => _medicalImages;
#endregion
#region Medical tests
private readonly List<VisitMedicalTest> _medicalTests = [];
public IReadOnlyCollection<VisitMedicalTest> MedicalTests => _medicalTests;
#endregion
#region Medicines
private readonly List<VisitMedicine> _medicines = [];
public IReadOnlyCollection<VisitMedicine> Medicines => _medicines;
#endregion
#endregion
......@@ -96,10 +110,7 @@ public sealed class Visit : Entity
throw;
}
if (MedicalImages is null)
MedicalImages = [];
MedicalImages.Add(entry);
_medicalImages.Add(entry);
}
#endregion
......@@ -115,9 +126,8 @@ public sealed class Visit : Entity
{
throw;
}
if (MedicalTests is null)
MedicalTests = [];
MedicalTests.Add(entry);
_medicalTests.Add(entry);
}
#endregion
......@@ -133,9 +143,8 @@ public sealed class Visit : Entity
{
throw;
}
if (Medicines is null)
Medicines = [];
Medicines.Add(entry);
_medicines.Add(entry);
}
#endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment