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
4e374cb3
You need to sign in or sign up before continuing.
Commit
4e374cb3
authored
Aug 21, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add register receptionist
parent
f228f27b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
1 deletion
+106
-1
RegisterReceptionistCommand.cs
...mands/RegisterReceptionist/RegisterReceptionistCommand.cs
+13
-0
RegisterReceptionistCommandHandler.cs
...egisterReceptionist/RegisterReceptionistCommandHandler.cs
+45
-0
RegisterReceptionistResponse.cs
...ands/RegisterReceptionist/RegisterReceptionistResponse.cs
+26
-0
UsersController.cs
Clinics.Backend/Presentation/Controllers/UsersController.cs
+22
-1
No files found.
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistCommand.cs
0 → 100644
View file @
4e374cb3
using
Application.Abstractions.CQRS.Commands
;
namespace
Application.Users.Commands.RegisterReceptionist
;
public
class
RegisterReceptionistCommand
:
ICommand
<
RegisterReceptionistResponse
>
{
public
string
UserName
{
get
;
set
;
}
=
null
!;
public
string
Password
{
get
;
set
;
}
=
null
!;
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
}
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistCommandHandler.cs
0 → 100644
View file @
4e374cb3
using
Application.Abstractions.CQRS.Commands
;
using
Application.Users.Commands.RegisterDoctor
;
using
Domain.Entities.Identity.Users
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Domain.UnitOfWork
;
namespace
Application.Users.Commands.RegisterReceptionist
;
public
class
RegisterReceptionistCommandHandler
:
CommandHandlerBase
<
RegisterReceptionistCommand
,
RegisterReceptionistResponse
>
{
#
region
CTOR
DI
private
readonly
IUserRepository
_userRepository
;
public
RegisterReceptionistCommandHandler
(
IUnitOfWork
unitOfWork
,
IUserRepository
userRepository
)
:
base
(
unitOfWork
)
{
_userRepository
=
userRepository
;
}
#
endregion
public
override
async
Task
<
Result
<
RegisterReceptionistResponse
>>
HandleHelper
(
RegisterReceptionistCommand
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Create
receptionist
user
Result
<
ReceptionistUser
>
receptionistUserResult
=
ReceptionistUser
.
Create
(
request
.
UserName
,
request
.
Password
,
request
.
FirstName
,
request
.
MiddleName
,
request
.
LastName
);
if
(
receptionistUserResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>(
receptionistUserResult
.
Error
);
#
endregion
#
region
2.
Register
(
save
to
DB
)
var
registerResult
=
await
_userRepository
.
RegisterReceptionistAsync
(
receptionistUserResult
.
Value
);
if
(
registerResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>(
registerResult
.
Error
);
#
endregion
return
RegisterReceptionistResponse
.
GetResponse
(
registerResult
.
Value
);
throw
new
NotImplementedException
();
}
}
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistResponse.cs
0 → 100644
View file @
4e374cb3
using
Application.Users.Commands.RegisterDoctor
;
using
Domain.Entities.Identity.Users
;
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Shared
;
using
Domain.Errors
;
using
Domain.Shared
;
namespace
Application.Users.Commands.RegisterReceptionist
;
public
class
RegisterReceptionistResponse
{
public
int
Id
{
get
;
set
;
}
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
=
null
!;
public
static
Result
<
RegisterReceptionistResponse
>
GetResponse
(
ReceptionistUser
receptionistUser
)
{
if
(
receptionistUser
is
null
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>(
IdentityErrors
.
NotFound
);
return
new
RegisterReceptionistResponse
{
Id
=
receptionistUser
.
Id
,
PersonalInfo
=
receptionistUser
.
PersonalInfo
};
}
}
Clinics.Backend/Presentation/Controllers/UsersController.cs
View file @
4e374cb3
using
Application.Users.Commands.Login
;
using
Application.Users.Commands.Login
;
using
Application.Users.Commands.RegisterDoctor
;
using
Application.Users.Commands.RegisterDoctor
;
using
Application.Users.Commands.RegisterReceptionist
;
using
Domain.Entities.Identity.UserRoles
;
using
Domain.Entities.Identity.UserRoles
;
using
MediatR
;
using
MediatR
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Authorization
;
...
@@ -18,6 +19,7 @@ public class UsersController : ApiController
...
@@ -18,6 +19,7 @@ public class UsersController : ApiController
}
}
#
endregion
#
endregion
#
region
Login
[
HttpPost
]
[
HttpPost
]
public
async
Task
<
IActionResult
>
LoginUser
([
FromBody
]
LoginCommand
command
)
public
async
Task
<
IActionResult
>
LoginUser
([
FromBody
]
LoginCommand
command
)
{
{
...
@@ -29,7 +31,10 @@ public class UsersController : ApiController
...
@@ -29,7 +31,10 @@ public class UsersController : ApiController
return
Ok
(
result
.
Value
);
return
Ok
(
result
.
Value
);
}
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
#
endregion
#
region
Doctors
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
[
HttpPost
(
"Doctors"
)]
[
HttpPost
(
"Doctors"
)]
public
async
Task
<
IActionResult
>
RegisterDoctor
([
FromBody
]
RegisterDoctorCommand
command
)
public
async
Task
<
IActionResult
>
RegisterDoctor
([
FromBody
]
RegisterDoctorCommand
command
)
{
{
...
@@ -40,5 +45,21 @@ public class UsersController : ApiController
...
@@ -40,5 +45,21 @@ public class UsersController : ApiController
return
Ok
(
result
.
Value
);
return
Ok
(
result
.
Value
);
}
}
#
endregion
#
region
Receptionist
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
[
HttpPost
(
"Receptionist"
)]
public
async
Task
<
IActionResult
>
RegisterReceptionist
([
FromBody
]
RegisterReceptionistCommand
command
)
{
var
result
=
await
_sender
.
Send
(
command
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
#
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