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
fb8a91f1
Commit
fb8a91f1
authored
Aug 20, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add user repo
parent
f3f4bf51
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
IdentityErrors.cs
Clinics.Backend/Domain/Errors/IdentityErrors.cs
+1
-0
IUserRepository.cs
Clinics.Backend/Domain/Repositories/IUserRepository.cs
+10
-0
FullUserSpecification.cs
...d/Persistence/Repositories/Users/FullUserSpecification.cs
+13
-0
UserRepository.cs
....Backend/Persistence/Repositories/Users/UserRepository.cs
+42
-0
No files found.
Clinics.Backend/Domain/Errors/IdentityErrors.cs
View file @
fb8a91f1
...
...
@@ -5,4 +5,5 @@ namespace Domain.Errors;
public
static
class
IdentityErrors
{
public
static
Error
InvalidRole
=>
new
(
"Identity.InvalidRole"
,
"Role specified for user is invalid"
);
public
static
Error
NotFound
=>
new
(
"Identity.NotFound"
,
"المستخدم غير مسجّل في النظام"
);
}
Clinics.Backend/Domain/Repositories/IUserRepository.cs
0 → 100644
View file @
fb8a91f1
using
Domain.Entities.Identity.Users
;
using
Domain.Repositories.Base
;
using
Domain.Shared
;
namespace
Domain.Repositories
;
public
interface
IUserRepository
:
IRepository
<
User
>
{
public
Task
<
Result
<
User
>>
GetByUserNameFullAsync
(
string
userName
);
}
Clinics.Backend/Persistence/Repositories/Users/FullUserSpecification.cs
0 → 100644
View file @
fb8a91f1
using
Domain.Entities.Identity.Users
;
using
Persistence.Repositories.Specifications.Base
;
using
System.Linq.Expressions
;
namespace
Persistence.Repositories.Users
;
public
class
FullUserSpecification
:
Specification
<
User
>
{
public
FullUserSpecification
(
Expression
<
Func
<
User
,
bool
>>?
criteria
)
:
base
(
criteria
)
{
AddInclude
(
user
=>
user
.
Role
);
}
}
Clinics.Backend/Persistence/Repositories/Users/UserRepository.cs
0 → 100644
View file @
fb8a91f1
using
Domain.Entities.Identity.Users
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Microsoft.EntityFrameworkCore
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
namespace
Persistence.Repositories.Users
;
public
class
UserRepository
:
Repositroy
<
User
>,
IUserRepository
{
#
region
Ctor
DI
public
UserRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
endregion
#
region
Create
method
public
override
Task
<
Result
<
User
>>
CreateAsync
(
User
entity
)
{
_context
.
Entry
(
entity
.
Role
).
State
=
EntityState
.
Unchanged
;
return
base
.
CreateAsync
(
entity
);
}
#
endregion
#
region
Get
by
username
public
async
Task
<
Result
<
User
>>
GetByUserNameFullAsync
(
string
userName
)
{
var
query
=
ApplySpecification
(
new
FullUserSpecification
(
user
=>
user
.
UserName
==
userName
));
var
result
=
await
query
.
ToListAsync
();
if
(
result
.
Count
==
0
)
{
return
Result
.
Failure
<
User
>(
IdentityErrors
.
NotFound
);
}
return
result
.
First
();
}
#
endregion
}
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