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
1ac4a103
Commit
1ac4a103
authored
Aug 26, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add get doctor status by user id query
parent
e406e0e8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
2 deletions
+72
-2
GetDoctorStatusByUserIdHandler.cs
...eries/GetStatusByUserId/GetDoctorStatusByUserIdHandler.cs
+30
-0
GetDoctorStatusByUserIdQuery.cs
...Queries/GetStatusByUserId/GetDoctorStatusByUserIdQuery.cs
+8
-0
GetDoctorStatusByUserIdResponse.cs
...ries/GetStatusByUserId/GetDoctorStatusByUserIdResponse.cs
+16
-0
UserRepository.cs
....Backend/Persistence/Repositories/Users/UserRepository.cs
+4
-2
DoctorsController.cs
...ics.Backend/Presentation/Controllers/DoctorsController.cs
+14
-0
No files found.
Clinics.Backend/Application/Doctors/Queries/GetStatusByUserId/GetDoctorStatusByUserIdHandler.cs
0 → 100644
View file @
1ac4a103
using
Application.Abstractions.CQRS.Queries
;
using
Domain.Repositories
;
using
Domain.Shared
;
namespace
Application.Doctors.Queries.GetStatusByUserId
;
public
class
GetDoctorStatusByUserIdHandler
:
IQueryHandler
<
GetDoctorStatusByUserIdQuery
,
GetDoctorStatusByUserIdResponse
>
{
#
region
CTOR
DI
private
readonly
IUserRepository
_userRepository
;
public
GetDoctorStatusByUserIdHandler
(
IUserRepository
userRepository
)
{
_userRepository
=
userRepository
;
}
#
endregion
public
async
Task
<
Result
<
GetDoctorStatusByUserIdResponse
>>
Handle
(
GetDoctorStatusByUserIdQuery
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
user
var
doctorUserFromPersistenceResult
=
await
_userRepository
.
GetDoctorUserByIdAsync
(
request
.
UserId
);
if
(
doctorUserFromPersistenceResult
.
IsFailure
)
return
Result
.
Failure
<
GetDoctorStatusByUserIdResponse
>(
doctorUserFromPersistenceResult
.
Error
);
var
doctorUser
=
doctorUserFromPersistenceResult
.
Value
;
#
endregion
return
Result
.
Success
<
GetDoctorStatusByUserIdResponse
>(
GetDoctorStatusByUserIdResponse
.
GetResponse
(
doctorUser
.
Doctor
));
}
}
Clinics.Backend/Application/Doctors/Queries/GetStatusByUserId/GetDoctorStatusByUserIdQuery.cs
0 → 100644
View file @
1ac4a103
using
Application.Abstractions.CQRS.Queries
;
namespace
Application.Doctors.Queries.GetStatusByUserId
;
public
class
GetDoctorStatusByUserIdQuery
:
IQuery
<
GetDoctorStatusByUserIdResponse
>
{
public
int
UserId
{
get
;
set
;
}
}
Clinics.Backend/Application/Doctors/Queries/GetStatusByUserId/GetDoctorStatusByUserIdResponse.cs
0 → 100644
View file @
1ac4a103
using
Domain.Entities.People.Doctors
;
namespace
Application.Doctors.Queries.GetStatusByUserId
;
public
class
GetDoctorStatusByUserIdResponse
{
public
string
Status
{
get
;
set
;
}
=
null
!;
public
static
GetDoctorStatusByUserIdResponse
GetResponse
(
Doctor
doctor
)
{
return
new
GetDoctorStatusByUserIdResponse
{
Status
=
doctor
.
Status
.
Name
};
}
}
Clinics.Backend/Persistence/Repositories/Users/UserRepository.cs
View file @
1ac4a103
...
...
@@ -164,7 +164,9 @@ public class UserRepository : Repositroy<User>, IUserRepository
.
Where
(
doctorUser
=>
doctorUser
.
Id
==
id
)
.
Include
(
doctorUser
=>
doctorUser
.
User
)
.
Include
(
doctorUser
=>
doctorUser
.
Doctor
)
.
ThenInclude
(
doctor
=>
doctor
.
PersonalInfo
);
.
ThenInclude
(
doctor
=>
doctor
.
PersonalInfo
)
.
Include
(
doctorUser
=>
doctorUser
.
Doctor
)
.
ThenInclude
(
doctor
=>
doctor
.
Status
);
return
await
query
.
FirstAsync
();
}
...
...
Clinics.Backend/Presentation/Controllers/DoctorsController.cs
View file @
1ac4a103
using
Application.Doctors.Queries.GetAllDoctors
;
using
Application.Doctors.Queries.GetStatusByUserId
;
using
Application.Employees.Queries.GetAvailable
;
using
Domain.Entities.Identity.UserRoles
;
using
MediatR
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Presentation.Controllers.Base
;
...
...
@@ -37,4 +40,15 @@ public class DoctorsController : ApiController
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
//[Authorize(Roles = Roles.DoctorName)]
[
HttpGet
(
"Status{id:int}"
)]
public
async
Task
<
IActionResult
>
GetStatusByUserId
([
FromRoute
(
Name
=
"id"
)]
int
userId
)
{
GetDoctorStatusByUserIdQuery
query
=
new
GetDoctorStatusByUserIdQuery
{
UserId
=
userId
};
var
result
=
await
_sender
.
Send
(
query
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
}
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