Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
almohanad.hafez
HIAST-Clinics
Commits
f1582a50
Commit
f1582a50
authored
Aug 16, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Update Employees-related entities
parent
bda3e985
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
251 additions
and
10 deletions
+251
-10
Employee.cs
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
+111
-2
EmployeeFamilyMember.cs
...s/Relations/EmployeeFamilyMembers/EmployeeFamilyMember.cs
+52
-1
FamilyRole.cs
...ions/EmployeeFamilyMembers/FamilyRoleValues/FamilyRole.cs
+35
-2
FamilyRoles.cs
...ons/EmployeeFamilyMembers/FamilyRoleValues/FamilyRoles.cs
+4
-4
EmployeeAdditionalInfo.cs
...ntities/People/Employees/Shared/EmployeeAdditionalInfo.cs
+47
-1
FamilyMember.cs
...kend/Domain/Entities/People/FamilyMembers/FamilyMember.cs
+2
-0
No files found.
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
View file @
f1582a50
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
using
Domain.Entities.People.Employees.Shared
;
using
Domain.Entities.People.Employees.Shared
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Entities.People.Patients
;
using
Domain.Entities.People.Patients
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees
;
namespace
Domain.Entities.People.Employees
;
public
sealed
class
Employee
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Employee
:
Entity
{
{
#
region
Private
ctor
private
Employee
(
int
id
)
:
base
(
id
)
{
}
private
Employee
(
int
id
,
Patient
patient
,
string
serialNumber
,
string
centerStatus
,
bool
isMarried
=
false
,
EmployeeAdditionalInfo
?
additionalInfo
=
null
)
:
base
(
id
)
{
Patient
=
patient
;
SerialNumber
=
serialNumber
;
CenterStatus
=
centerStatus
;
IsMarried
=
isMarried
;
AdditionalInfo
=
additionalInfo
;
}
#
endregion
#
region
Properties
#
region
Properties
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
...
@@ -17,7 +38,7 @@ public sealed class Employee(int id) : Entity(id)
...
@@ -17,7 +38,7 @@ public sealed class Employee(int id) : Entity(id)
public
string
CenterStatus
{
get
;
set
;
}
=
null
!;
public
string
CenterStatus
{
get
;
set
;
}
=
null
!;
public
bool
IsMarried
{
get
;
set
;
}
=
false
;
public
bool
IsMarried
{
get
;
set
;
}
#
region
Navigations
#
region
Navigations
...
@@ -31,6 +52,94 @@ public sealed class Employee(int id) : Entity(id)
...
@@ -31,6 +52,94 @@ public sealed class Employee(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Employee
Create
(
string
firstName
,
string
middleName
,
string
lastName
,
DateOnly
dateOfBirth
,
string
gender
,
string
serialNumber
,
string
centerStatus
,
bool
isMarried
=
false
,
DateOnly
?
startDate
=
null
,
string
?
academicQualification
=
null
,
string
?
workPhone
=
null
,
string
?
location
=
null
,
string
?
specialization
=
null
,
string
?
jobStatus
=
null
,
string
?
imageUrl
=
null
)
{
#
region
Create
patient
Patient
patient
;
try
{
patient
=
Patient
.
Create
(
firstName
,
middleName
,
lastName
,
dateOfBirth
,
gender
);
}
catch
{
throw
;
}
#
endregion
#
region
Check
employee
'
s
required
details
if
(
serialNumber
is
null
||
centerStatus
is
null
)
throw
new
InvalidValuesDomainException
<
Employee
>();
#
endregion
#
region
Create
additional
info
EmployeeAdditionalInfo
additionalInfo
;
try
{
additionalInfo
=
EmployeeAdditionalInfo
.
Create
(
startDate
,
academicQualification
,
workPhone
,
location
,
specialization
,
jobStatus
,
imageUrl
);
}
catch
{
throw
;
}
#
endregion
return
new
Employee
(
0
,
patient
,
serialNumber
,
centerStatus
,
isMarried
,
additionalInfo
);
}
#
endregion
#
region
Add
family
member
public
void
AddFamilyMember
(
FamilyMember
familyMember
,
string
role
)
{
EmployeeFamilyMember
employeeFamilyMember
;
try
{
employeeFamilyMember
=
EmployeeFamilyMember
.
Create
(
Id
,
familyMember
.
Id
,
role
);
}
catch
{
throw
;
}
if
(
FamilyMembers
is
null
)
FamilyMembers
=
[];
FamilyMembers
.
Add
(
employeeFamilyMember
);
}
#
endregion
#
region
Add
related
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
);
}
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/EmployeeFamilyMember.cs
View file @
f1582a50
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
using
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers
;
public
sealed
class
EmployeeFamilyMember
(
int
id
)
:
Entity
(
id
)
public
sealed
class
EmployeeFamilyMember
:
Entity
{
{
#
region
Private
ctor
private
EmployeeFamilyMember
(
int
id
)
:
base
(
id
)
{
}
private
EmployeeFamilyMember
(
int
id
,
int
employeeId
,
int
familyMemberId
,
FamilyRole
role
)
:
base
(
id
)
{
EmployeeId
=
employeeId
;
FamilyMemberId
=
familyMemberId
;
Role
=
role
;
}
#
endregion
#
region
Properties
#
region
Properties
#
region
Employee
#
region
Employee
...
@@ -29,4 +42,42 @@ public sealed class EmployeeFamilyMember(int id) : Entity(id)
...
@@ -29,4 +42,42 @@ public sealed class EmployeeFamilyMember(int id) : Entity(id)
#
endregion
#
endregion
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
EmployeeFamilyMember
Create
(
int
employeeId
,
int
familyMemberId
,
string
role
)
{
if
(
employeeId
<=
0
||
familyMemberId
<=
0
||
role
is
null
)
throw
new
InvalidValuesDomainException
<
EmployeeFamilyMember
>();
#
region
Check
role
FamilyRole
?
selectedRole
;
FamilyRole
husband
=
FamilyRoles
.
Husband
;
FamilyRole
wife
=
FamilyRoles
.
Wife
;
FamilyRole
son
=
FamilyRoles
.
Son
;
FamilyRole
daughter
=
FamilyRoles
.
Daughter
;
if
(
role
==
husband
.
Name
)
selectedRole
=
husband
;
else
if
(
role
==
wife
.
Name
)
selectedRole
=
wife
;
else
if
(
role
==
son
.
Name
)
selectedRole
=
son
;
else
if
(
role
==
daughter
.
Name
)
selectedRole
=
daughter
;
else
selectedRole
=
null
;
if
(
selectedRole
is
null
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
#
endregion
return
new
EmployeeFamilyMember
(
0
,
employeeId
,
familyMemberId
,
selectedRole
);
}
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/FamilyRoleValues/FamilyRole.cs
View file @
f1582a50
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
namespace
Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues
;
public
sealed
class
FamilyRole
(
int
id
)
:
Entity
(
id
)
public
sealed
class
FamilyRole
:
Entity
{
{
#
region
Private
ctor
private
FamilyRole
(
int
id
)
:
base
(
id
)
{
}
private
FamilyRole
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
public
string
Name
{
get
;
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
FamilyRole
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
if
(
id
is
not
null
)
{
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
FamilyRole
>();
return
new
FamilyRole
(
id
.
Value
,
name
);
}
return
new
FamilyRole
(
0
,
name
);
}
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Employees/Relations/EmployeeFamilyMembers/FamilyRoleValues/FamilyRoles.cs
View file @
f1582a50
...
@@ -4,13 +4,13 @@ public static class FamilyRoles
...
@@ -4,13 +4,13 @@ public static class FamilyRoles
{
{
#
region
Constant
id
values
#
region
Constant
id
values
public
static
int
Husband
=>
1
;
public
static
FamilyRole
Husband
=>
FamilyRole
.
Create
(
"زوج"
,
1
)
;
public
static
int
Wife
=>
2
;
public
static
FamilyRole
Wife
=>
FamilyRole
.
Create
(
"زوجة"
,
2
)
;
public
static
int
Son
=>
3
;
public
static
FamilyRole
Son
=>
FamilyRole
.
Create
(
"ابن"
,
3
)
;
public
static
int
Daughter
=>
4
;
public
static
FamilyRole
Daughter
=>
FamilyRole
.
Create
(
"ابنة"
,
4
)
;
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Employees/Shared/EmployeeAdditionalInfo.cs
View file @
f1582a50
...
@@ -3,8 +3,36 @@
...
@@ -3,8 +3,36 @@
namespace
Domain.Entities.People.Employees.Shared
;
namespace
Domain.Entities.People.Employees.Shared
;
// TODO: Convert to a value object containig value objects
// TODO: Convert to a value object containig value objects
public
sealed
class
EmployeeAdditionalInfo
(
int
id
)
:
Entity
(
id
)
public
sealed
class
EmployeeAdditionalInfo
:
Entity
{
{
#
region
Private
ctor
private
EmployeeAdditionalInfo
(
int
id
)
:
base
(
id
)
{
}
private
EmployeeAdditionalInfo
(
int
id
,
DateOnly
?
startDate
,
string
?
academicQualification
,
string
?
workPhone
,
string
?
location
,
string
?
specialization
,
string
?
jobStatus
,
string
?
imageUrl
)
:
base
(
id
)
{
StartDate
=
startDate
;
AcademicQualification
=
academicQualification
;
WorkPhone
=
workPhone
;
Location
=
location
;
Specialization
=
specialization
;
JobStatus
=
jobStatus
;
ImageUrl
=
imageUrl
;
}
#
endregion
#
region
Properties
#
region
Properties
public
DateOnly
?
StartDate
{
get
;
set
;
}
public
DateOnly
?
StartDate
{
get
;
set
;
}
...
@@ -22,4 +50,22 @@ public sealed class EmployeeAdditionalInfo(int id) : Entity(id)
...
@@ -22,4 +50,22 @@ public sealed class EmployeeAdditionalInfo(int id) : Entity(id)
public
string
?
ImageUrl
{
get
;
set
;
}
public
string
?
ImageUrl
{
get
;
set
;
}
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
EmployeeAdditionalInfo
Create
(
DateOnly
?
startDate
,
string
?
academicQualification
,
string
?
workPhone
,
string
?
location
,
string
?
specialization
,
string
?
jobStatus
,
string
?
imageUrl
)
{
return
new
EmployeeAdditionalInfo
(
0
,
startDate
,
academicQualification
,
workPhone
,
location
,
specialization
,
jobStatus
,
imageUrl
);
}
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/FamilyMembers/FamilyMember.cs
View file @
f1582a50
...
@@ -30,6 +30,7 @@ public sealed class FamilyMember : Entity
...
@@ -30,6 +30,7 @@ public sealed class FamilyMember : Entity
string
gender
string
gender
)
)
{
{
#
region
Create
patient
Patient
patient
;
Patient
patient
;
try
try
...
@@ -40,6 +41,7 @@ public sealed class FamilyMember : Entity
...
@@ -40,6 +41,7 @@ public sealed class FamilyMember : Entity
{
{
throw
;
throw
;
}
}
#
endregion
return
new
FamilyMember
(
0
,
patient
);
return
new
FamilyMember
(
0
,
patient
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment