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
2682fdbb
Commit
2682fdbb
authored
Aug 19, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add patients repo with specification
parent
400a6cbb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
7 deletions
+86
-7
IPatientsRepository.cs
Clinics.Backend/Domain/Repositories/IPatientsRepository.cs
+14
-0
EmployeesRepository.cs
...Persistence/Repositories/Employees/EmployeesRepository.cs
+4
-4
EmployeeFamilyMembersRepository.cs
...es/Employees/Relations/EmployeeFamilyMembersRepository.cs
+1
-1
FamilyMembersRepository.cs
...nce/Repositories/FamilyMembers/FamilyMembersRepository.cs
+2
-2
PatientsRepository.cs
...d/Persistence/Repositories/Patients/PatientsRepository.cs
+51
-0
FullSpecification.cs
...Repositories/Patients/Specifications/FullSpecification.cs
+14
-0
No files found.
Clinics.Backend/Domain/Repositories/IPatientsRepository.cs
0 → 100644
View file @
2682fdbb
using
Domain.Entities.People.Patients
;
using
Domain.Repositories.Base
;
using
Domain.Shared
;
namespace
Domain.Repositories
;
public
interface
IPatientsRepository
:
IRepository
<
Patient
>
{
#
region
Read
operations
FULL
public
Task
<
Result
<
Patient
>>
GetByIdFullAsync
(
int
id
);
public
Task
<
Result
<
ICollection
<
Patient
>>>
GetAllFullAsync
(
int
id
);
#
endregion
}
Clinics.Backend/Persistence/Repositories/EmployeesRepository.cs
→
Clinics.Backend/Persistence/Repositories/Employees
/Employees
Repository.cs
View file @
2682fdbb
...
@@ -6,11 +6,11 @@ using Microsoft.EntityFrameworkCore;
...
@@ -6,11 +6,11 @@ using Microsoft.EntityFrameworkCore;
using
Persistence.Context
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
using
Persistence.Repositories.Base
;
namespace
Persistence.Repositories
;
namespace
Persistence.Repositories
.Employees
;
public
class
EmployeesRepository
:
Repositroy
<
Employee
>,
IEmployeesRepository
public
class
EmployeesRepository
:
Repositroy
<
Employee
>,
IEmployeesRepository
{
{
public
EmployeesRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{}
public
EmployeesRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
region
Create
method
#
region
Create
method
public
override
Task
<
Result
<
Employee
>>
CreateAsync
(
Employee
entity
)
public
override
Task
<
Result
<
Employee
>>
CreateAsync
(
Employee
entity
)
...
@@ -22,12 +22,12 @@ public class EmployeesRepository : Repositroy<Employee>, IEmployeesRepository
...
@@ -22,12 +22,12 @@ public class EmployeesRepository : Repositroy<Employee>, IEmployeesRepository
#
endregion
#
endregion
#
region
Get
by
serial
Number
#
region
Get
by
serial
Number
public
async
Task
<
Result
<
Employee
>>
GetEmployeeBySerialNumberAsync
(
string
serialNumber
)
public
async
Task
<
Result
<
Employee
>>
GetEmployeeBySerialNumberAsync
(
string
serialNumber
)
{
{
var
all
=
await
_context
.
Set
<
Employee
>().
Where
(
employee
=>
employee
.
SerialNumber
==
serialNumber
).
ToListAsync
();
var
all
=
await
_context
.
Set
<
Employee
>().
Where
(
employee
=>
employee
.
SerialNumber
==
serialNumber
).
ToListAsync
();
if
(
all
.
Count
!=
1
)
if
(
all
.
Count
!=
1
)
return
Result
.
Failure
<
Employee
>(
PersistenceErrors
.
NotFound
);
return
Result
.
Failure
<
Employee
>(
PersistenceErrors
.
NotFound
);
return
Result
.
Success
<
Employee
>
(
all
.
First
());
return
Result
.
Success
(
all
.
First
());
}
}
#
endregion
#
endregion
}
}
Clinics.Backend/Persistence/Repositories/EmployeeFamilyMembersRepository.cs
→
Clinics.Backend/Persistence/Repositories/Employee
s/Relations/Employee
FamilyMembersRepository.cs
View file @
2682fdbb
...
@@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
...
@@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using
Persistence.Context
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
using
Persistence.Repositories.Base
;
namespace
Persistence.Repositories
;
namespace
Persistence.Repositories
.Employees.Relations
;
public
class
EmployeeFamilyMembersRepository
:
Repositroy
<
EmployeeFamilyMember
>,
IEmployeeFamilyMembersRepository
public
class
EmployeeFamilyMembersRepository
:
Repositroy
<
EmployeeFamilyMember
>,
IEmployeeFamilyMembersRepository
{
{
...
...
Clinics.Backend/Persistence/Repositories/FamilyMembersRepository.cs
→
Clinics.Backend/Persistence/Repositories/FamilyMembers
/FamilyMembers
Repository.cs
View file @
2682fdbb
...
@@ -5,12 +5,12 @@ using Microsoft.EntityFrameworkCore;
...
@@ -5,12 +5,12 @@ using Microsoft.EntityFrameworkCore;
using
Persistence.Context
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
using
Persistence.Repositories.Base
;
namespace
Persistence.Repositories
;
namespace
Persistence.Repositories
.FamilyMembers
;
public
class
FamilyMembersRepository
:
Repositroy
<
FamilyMember
>,
IFamilyMembersRepository
public
class
FamilyMembersRepository
:
Repositroy
<
FamilyMember
>,
IFamilyMembersRepository
{
{
#
region
CTOR
DI
for
context
#
region
CTOR
DI
for
context
public
FamilyMembersRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{}
public
FamilyMembersRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
endregion
#
endregion
#
region
Create
method
#
region
Create
method
...
...
Clinics.Backend/Persistence/Repositories/Patients/PatientsRepository.cs
0 → 100644
View file @
2682fdbb
using
Domain.Entities.People.Patients
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Microsoft.EntityFrameworkCore
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
using
Persistence.Repositories.Patients.Specifications
;
namespace
Persistence.Repositories.Patients
;
public
class
PatientsRepository
:
Repositroy
<
Patient
>,
IPatientsRepository
{
#
region
CTOR
DI
for
context
public
PatientsRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
endregion
#
region
Read
operations
FULL
public
async
Task
<
Result
<
ICollection
<
Patient
>>>
GetAllFullAsync
(
int
id
)
{
var
query
=
ApplySpecification
(
new
FullSpecification
(
patient
=>
true
));
// Get all
try
{
var
patients
=
await
query
.
ToListAsync
();
return
Result
.
Success
<
ICollection
<
Patient
>>(
patients
);
}
catch
(
Exception
)
{
return
Result
.
Failure
<
ICollection
<
Patient
>>(
PersistenceErrors
.
NotFound
);
}
}
public
async
Task
<
Result
<
Patient
>>
GetByIdFullAsync
(
int
id
)
{
var
query
=
ApplySpecification
(
new
FullSpecification
(
patient
=>
patient
.
Id
==
id
));
// Get all
try
{
var
patient
=
await
query
.
FirstAsync
();
return
Result
.
Success
<
Patient
>(
patient
);
}
catch
(
Exception
)
{
return
Result
.
Failure
<
Patient
>(
PersistenceErrors
.
NotFound
);
}
}
#
endregion
}
Clinics.Backend/Persistence/Repositories/Patients/Specifications/FullSpecification.cs
0 → 100644
View file @
2682fdbb
using
Domain.Entities.People.Patients
;
using
Persistence.Repositories.Specifications.Base
;
using
System.Linq.Expressions
;
namespace
Persistence.Repositories.Patients.Specifications
;
public
class
FullSpecification
:
Specification
<
Patient
>
{
public
FullSpecification
(
Expression
<
Func
<
Patient
,
bool
>>?
criteria
)
:
base
(
criteria
)
{
AddInclude
(
patient
=>
patient
.
PersonalInfo
);
AddInclude
(
patient
=>
patient
.
Gender
);
}
}
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