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
852fc824
Commit
852fc824
authored
Aug 22, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Edit register response
parent
98a22859
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
71 deletions
+18
-71
RegisterDoctorCommand.cs
...on/Users/Commands/RegisterDoctor/RegisterDoctorCommand.cs
+1
-1
RegisterDoctorHandler.cs
...on/Users/Commands/RegisterDoctor/RegisterDoctorHandler.cs
+7
-7
RegisterDoctorResponse.cs
...n/Users/Commands/RegisterDoctor/RegisterDoctorResponse.cs
+0
-24
RegisterReceptionistCommand.cs
...mands/RegisterReceptionist/RegisterReceptionistCommand.cs
+1
-1
RegisterReceptionistCommandHandler.cs
...egisterReceptionist/RegisterReceptionistCommandHandler.cs
+7
-10
RegisterReceptionistResponse.cs
...ands/RegisterReceptionist/RegisterReceptionistResponse.cs
+0
-26
UsersController.cs
Clinics.Backend/Presentation/Controllers/UsersController.cs
+2
-2
No files found.
Clinics.Backend/Application/Users/Commands/RegisterDoctor/RegisterDoctorCommand.cs
View file @
852fc824
...
...
@@ -2,7 +2,7 @@
namespace
Application.Users.Commands.RegisterDoctor
;
public
class
RegisterDoctorCommand
:
ICommand
<
RegisterDoctorResponse
>
public
class
RegisterDoctorCommand
:
ICommand
{
public
string
UserName
{
get
;
set
;
}
=
null
!;
public
string
Password
{
get
;
set
;
}
=
null
!;
...
...
Clinics.Backend/Application/Users/Commands/RegisterDoctor/RegisterDoctorHandler.cs
View file @
852fc824
...
...
@@ -7,7 +7,7 @@ using Domain.UnitOfWork;
namespace
Application.Users.Commands.RegisterDoctor
;
public
class
RegisterDoctorHandler
:
CommandHandlerBase
<
RegisterDoctorCommand
,
RegisterDoctorResponse
>
public
class
RegisterDoctorHandler
:
CommandHandlerBase
<
RegisterDoctorCommand
>
{
#
region
CTOR
DI
private
readonly
IUserRepository
_userRepository
;
...
...
@@ -18,7 +18,7 @@ public class RegisterDoctorHandler : CommandHandlerBase<RegisterDoctorCommand, R
#
endregion
public
override
async
Task
<
Result
<
RegisterDoctorResponse
>
>
HandleHelper
(
RegisterDoctorCommand
request
,
CancellationToken
cancellationToken
)
public
override
async
Task
<
Result
>
HandleHelper
(
RegisterDoctorCommand
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Create
doctor
user
Result
<
DoctorUser
>
doctorUserResult
=
DoctorUser
.
Create
(
...
...
@@ -28,23 +28,23 @@ public class RegisterDoctorHandler : CommandHandlerBase<RegisterDoctorCommand, R
);
if
(
doctorUserResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterDoctorResponse
>
(
doctorUserResult
.
Error
);
return
Result
.
Failure
(
doctorUserResult
.
Error
);
#
endregion
#
region
2.
Verify
unique
username
var
uniqueUserNameResult
=
await
_userRepository
.
IsUserNameAvailableAsunc
(
request
.
UserName
);
if
(
uniqueUserNameResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterDoctorResponse
>
(
uniqueUserNameResult
.
Error
);
return
Result
.
Failure
(
uniqueUserNameResult
.
Error
);
if
(
uniqueUserNameResult
.
Value
==
false
)
return
Result
.
Failure
<
RegisterDoctorResponse
>
(
IdentityErrors
.
TakenUserName
);
return
Result
.
Failure
(
IdentityErrors
.
TakenUserName
);
#
endregion
#
region
3.
Register
(
save
to
DB
)
var
registerResult
=
await
_userRepository
.
RegisterDoctorAsync
(
doctorUserResult
.
Value
);
if
(
registerResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterDoctorResponse
>
(
registerResult
.
Error
);
return
Result
.
Failure
(
registerResult
.
Error
);
#
endregion
return
Re
gisterDoctorResponse
.
GetResponse
(
registerResult
.
Value
);
return
Re
sult
.
Success
(
);
}
}
Clinics.Backend/Application/Users/Commands/RegisterDoctor/RegisterDoctorResponse.cs
deleted
100644 → 0
View file @
98a22859
using
Domain.Entities.Identity.Users
;
using
Domain.Entities.People.Doctors
;
using
Domain.Errors
;
using
Domain.Shared
;
namespace
Application.Users.Commands.RegisterDoctor
;
public
class
RegisterDoctorResponse
{
public
int
Id
{
get
;
set
;
}
public
Doctor
Doctor
{
get
;
set
;
}
=
null
!;
public
static
Result
<
RegisterDoctorResponse
>
GetResponse
(
DoctorUser
doctorUser
)
{
if
(
doctorUser
is
null
)
return
Result
.
Failure
<
RegisterDoctorResponse
>(
IdentityErrors
.
NotFound
);
return
new
RegisterDoctorResponse
{
Id
=
doctorUser
.
Id
,
Doctor
=
doctorUser
.
Doctor
};
}
}
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistCommand.cs
View file @
852fc824
...
...
@@ -2,7 +2,7 @@
namespace
Application.Users.Commands.RegisterReceptionist
;
public
class
RegisterReceptionistCommand
:
ICommand
<
RegisterReceptionistResponse
>
public
class
RegisterReceptionistCommand
:
ICommand
{
public
string
UserName
{
get
;
set
;
}
=
null
!;
public
string
Password
{
get
;
set
;
}
=
null
!;
...
...
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistCommandHandler.cs
View file @
852fc824
...
...
@@ -8,7 +8,7 @@ using Domain.UnitOfWork;
namespace
Application.Users.Commands.RegisterReceptionist
;
public
class
RegisterReceptionistCommandHandler
:
CommandHandlerBase
<
RegisterReceptionistCommand
,
RegisterReceptionistResponse
>
public
class
RegisterReceptionistCommandHandler
:
CommandHandlerBase
<
RegisterReceptionistCommand
>
{
#
region
CTOR
DI
private
readonly
IUserRepository
_userRepository
;
...
...
@@ -19,7 +19,7 @@ public class RegisterReceptionistCommandHandler : CommandHandlerBase<RegisterRec
#
endregion
public
override
async
Task
<
Result
<
RegisterReceptionistResponse
>
>
HandleHelper
(
RegisterReceptionistCommand
request
,
CancellationToken
cancellationToken
)
public
override
async
Task
<
Result
>
HandleHelper
(
RegisterReceptionistCommand
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Create
receptionist
user
Result
<
ReceptionistUser
>
receptionistUserResult
=
ReceptionistUser
.
Create
(
...
...
@@ -29,26 +29,23 @@ public class RegisterReceptionistCommandHandler : CommandHandlerBase<RegisterRec
);
if
(
receptionistUserResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>
(
receptionistUserResult
.
Error
);
return
Result
.
Failure
(
receptionistUserResult
.
Error
);
#
endregion
#
region
2.
Verify
unique
username
var
uniqueUserNameResult
=
await
_userRepository
.
IsUserNameAvailableAsunc
(
request
.
UserName
);
if
(
uniqueUserNameResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>
(
uniqueUserNameResult
.
Error
);
return
Result
.
Failure
(
uniqueUserNameResult
.
Error
);
if
(
uniqueUserNameResult
.
Value
==
false
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>
(
IdentityErrors
.
TakenUserName
);
return
Result
.
Failure
(
IdentityErrors
.
TakenUserName
);
#
endregion
#
region
3.
Register
(
save
to
DB
)
var
registerResult
=
await
_userRepository
.
RegisterReceptionistAsync
(
receptionistUserResult
.
Value
);
if
(
registerResult
.
IsFailure
)
return
Result
.
Failure
<
RegisterReceptionistResponse
>
(
registerResult
.
Error
);
return
Result
.
Failure
(
registerResult
.
Error
);
#
endregion
return
RegisterReceptionistResponse
.
GetResponse
(
registerResult
.
Value
);
throw
new
NotImplementedException
();
return
Result
.
Success
();
}
}
Clinics.Backend/Application/Users/Commands/RegisterReceptionist/RegisterReceptionistResponse.cs
deleted
100644 → 0
View file @
98a22859
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 @
852fc824
...
...
@@ -45,7 +45,7 @@ public class UsersController : ApiController
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
return
Created
(
);
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
...
...
@@ -70,7 +70,7 @@ public class UsersController : ApiController
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
return
Created
(
);
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
[
HttpGet
(
"Receptionists"
)]
...
...
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