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
77aa7142
Commit
77aa7142
authored
Aug 25, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add id to create employee response
parent
97f00868
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
8 deletions
+21
-8
CreateEmployeeCommand.cs
...mployees/Commands/CreateEmployee/CreateEmployeeCommand.cs
+1
-1
CreateEmployeeCommandHandler.cs
...s/Commands/CreateEmployee/CreateEmployeeCommandHandler.cs
+6
-6
CreateEmployeeCommandResponse.cs
.../Commands/CreateEmployee/CreateEmployeeCommandResponse.cs
+13
-0
EmployeesController.cs
...s.Backend/Presentation/Controllers/EmployeesController.cs
+1
-1
No files found.
Clinics.Backend/Application/Employees/Commands/CreateEmployee/CreateEmployeeCommand.cs
View file @
77aa7142
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
Application.Employees.Commands.CreateEmployee
;
namespace
Application.Employees.Commands.CreateEmployee
;
public
class
CreateEmployeeCommand
:
ICommand
public
class
CreateEmployeeCommand
:
ICommand
<
CreateEmployeeCommandResponse
>
{
{
// Future update: Employees data will be fetched from ID system's API
// Future update: Employees data will be fetched from ID system's API
...
...
Clinics.Backend/Application/Employees/Commands/CreateEmployee/CreateEmployeeCommandHandler.cs
View file @
77aa7142
...
@@ -7,7 +7,7 @@ using Domain.UnitOfWork;
...
@@ -7,7 +7,7 @@ using Domain.UnitOfWork;
namespace
Application.Employees.Commands.CreateEmployee
;
namespace
Application.Employees.Commands.CreateEmployee
;
public
class
CreateEmployeeCommandHandler
:
CommandHandlerBase
<
CreateEmployeeCommand
>
public
class
CreateEmployeeCommandHandler
:
CommandHandlerBase
<
CreateEmployeeCommand
,
CreateEmployeeCommandResponse
>
{
{
#
region
CTOR
DI
#
region
CTOR
DI
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
IEmployeesRepository
_employeesRepository
;
...
@@ -19,7 +19,7 @@ public class CreateEmployeeCommandHandler : CommandHandlerBase<CreateEmployeeCom
...
@@ -19,7 +19,7 @@ public class CreateEmployeeCommandHandler : CommandHandlerBase<CreateEmployeeCom
#
endregion
#
endregion
public
override
async
Task
<
Result
>
HandleHelper
(
CreateEmployeeCommand
request
,
CancellationToken
cancellationToken
)
public
override
async
Task
<
Result
<
CreateEmployeeCommandResponse
>
>
HandleHelper
(
CreateEmployeeCommand
request
,
CancellationToken
cancellationToken
)
{
{
#
region
1.
Create
employee
#
region
1.
Create
employee
...
@@ -34,21 +34,21 @@ public class CreateEmployeeCommandHandler : CommandHandlerBase<CreateEmployeeCom
...
@@ -34,21 +34,21 @@ public class CreateEmployeeCommandHandler : CommandHandlerBase<CreateEmployeeCom
request
.
JobStatus
request
.
JobStatus
);
);
if
(
employeeResult
.
IsFailure
)
if
(
employeeResult
.
IsFailure
)
return
Result
.
Failure
(
employeeResult
.
Error
);
return
Result
.
Failure
<
CreateEmployeeCommandResponse
>
(
employeeResult
.
Error
);
#
endregion
#
endregion
#
region
2.
Check
existed
serial
number
#
region
2.
Check
existed
serial
number
Result
<
Employee
>
existedResult
=
await
_employeesRepository
.
GetEmployeeBySerialNumberAsync
(
request
.
SerialNumber
);
Result
<
Employee
>
existedResult
=
await
_employeesRepository
.
GetEmployeeBySerialNumberAsync
(
request
.
SerialNumber
);
if
(
existedResult
.
IsSuccess
)
if
(
existedResult
.
IsSuccess
)
return
Result
.
Failure
(
DomainErrors
.
EmployeeAlreadyExist
);
return
Result
.
Failure
<
CreateEmployeeCommandResponse
>
(
DomainErrors
.
EmployeeAlreadyExist
);
#
endregion
#
endregion
#
region
3.
Add
to
DB
#
region
3.
Add
to
DB
var
createResult
=
await
_employeesRepository
.
CreateAsync
(
employeeResult
.
Value
);
var
createResult
=
await
_employeesRepository
.
CreateAsync
(
employeeResult
.
Value
);
if
(
createResult
.
IsFailure
)
if
(
createResult
.
IsFailure
)
return
Result
.
Failure
(
createResult
.
Error
);
return
Result
.
Failure
<
CreateEmployeeCommandResponse
>
(
createResult
.
Error
);
#
endregion
#
endregion
return
Result
.
Success
();
return
Result
.
Success
(
CreateEmployeeCommandResponse
.
GetResponse
(
createResult
.
Value
)
);
}
}
}
}
Clinics.Backend/Application/Employees/Commands/CreateEmployee/CreateEmployeeCommandResponse.cs
0 → 100644
View file @
77aa7142
using
Domain.Entities.People.Employees
;
namespace
Application.Employees.Commands.CreateEmployee
;
public
class
CreateEmployeeCommandResponse
{
public
int
Id
{
get
;
set
;
}
public
static
CreateEmployeeCommandResponse
GetResponse
(
Employee
employee
)
{
return
new
CreateEmployeeCommandResponse
{
Id
=
employee
.
Id
};
}
}
Clinics.Backend/Presentation/Controllers/EmployeesController.cs
View file @
77aa7142
...
@@ -27,7 +27,7 @@ public class EmployeesController : ApiController
...
@@ -27,7 +27,7 @@ public class EmployeesController : ApiController
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
if
(
result
.
IsFailure
)
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
HandleFailure
(
result
);
return
Created
(
);
return
Ok
(
result
.
Value
);
}
}
//[Authorize(Roles = Roles.ReceptionistName)]
//[Authorize(Roles = Roles.ReceptionistName)]
...
...
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