Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
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
hasan.bahjat
ProjectsStatusManagement
Commits
57363ef1
Commit
57363ef1
authored
Aug 21, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add handler request to map the result
parent
e44cd7d2
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
103 additions
and
89 deletions
+103
-89
APIController.cs
PSManagement.Api/Controllers/ApiBase/APIController.cs
+16
-1
AuthenticationController.cs
...pi/Controllers/Authentication/AuthenticationController.cs
+9
-14
CustomersController.cs
...nagement.Api/Controllers/Customers/CustomersController.cs
+9
-9
EmployeesController.cs
...nagement.Api/Controllers/Employees/EmployeesController.cs
+11
-11
FinancialSpendsController.cs
.../Controllers/FinancialSpends/FinancialSpendsController.cs
+6
-6
ProjectsController.cs
PSManagement.Api/Controllers/Projects/ProjectsController.cs
+16
-16
RolesController.cs
PSManagement.Api/Controllers/Roles/RolesController.cs
+5
-5
UserRolesController.cs
PSManagement.Api/Controllers/Roles/UserRolesController.cs
+6
-6
StepsController.cs
PSManagement.Api/Controllers/Steps/StepsController.cs
+7
-7
TracksController.cs
PSManagement.Api/Controllers/Tracks/TracksController.cs
+12
-12
CustomerMapperConfiguration.cs
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
+4
-1
AddParticipantCommandHandler.cs
...s/Commands/AddParticipant/AddParticipantCommandHandler.cs
+1
-1
GetStepsByProjectQueryHandler.cs
...ueries/GetStepsByProject/GetStepsByProjectQueryHandler.cs
+1
-0
No files found.
PSManagement.Api/Controllers/ApiBase/APIController.cs
View file @
57363ef1
using
Microsoft.AspNetCore.Http
;
using
Ardalis.Result
;
using
MediatR
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -11,5 +13,18 @@ namespace PSManagement.Api.Controllers.ApiBase
[
ApiController
]
public
class
APIController
:
ControllerBase
{
protected
IActionResult
HandleResult
<
T
>(
Result
<
T
>
result
)
{
if
(
result
.
IsSuccess
)
{
return
Ok
(
result
.
Value
);
}
else
{
return
Problem
(
detail
:
result
.
Errors
.
FirstOrDefault
(),
statusCode
:
StatusCodes
.
Status400BadRequest
);
}
}
}
}
PSManagement.Api/Controllers/Authentication/AuthenticationController.cs
View file @
57363ef1
...
...
@@ -6,6 +6,7 @@ using PSManagement.Application.Contracts.Authentication;
using
PSManagement.Contracts.Authentication
;
using
System.Threading.Tasks
;
using
AuthenticationResponse
=
PSManagement
.
Contracts
.
Authentication
.
AuthenticationResponse
;
using
AutoMapper
;
namespace
PSManagement.Api.Controllers.Authentication
{
...
...
@@ -13,29 +14,23 @@ namespace PSManagement.Api.Controllers.Authentication
public
class
AuthenticationController
:
APIController
{
private
readonly
IAuthenticationService
_authenticationService
;
public
AuthenticationController
(
IAuthenticationService
authenticationService
)
private
readonly
IMapper
_mapper
;
public
AuthenticationController
(
IAuthenticationService
authenticationService
,
IMapper
mapper
)
{
_authenticationService
=
authenticationService
;
_mapper
=
mapper
;
}
[
HttpPost
(
"Login"
)]
public
async
Task
<
IActionResult
>
Login
([
FromBody
]
LoginRequest
loginRequest
)
{
Result
<
AuthenticationResult
>
result
=
await
_authenticationService
.
Login
(
loginRequest
.
Email
,
loginRequest
.
PassWord
);
if
(
result
.
IsSuccess
)
{
AuthenticationResponse
response
=
new
(
result
.
Value
.
EmployeeId
,
result
.
Value
.
FirstName
,
result
.
Value
.
LastName
,
result
.
Value
.
Email
,
result
.
Value
.
Roles
,
result
.
Value
.
Token
);
return
Ok
(
response
);
}
return
Problem
(
title
:
result
.
ValidationErrors
.
FirstOrDefault
().
ErrorCode
,
detail
:
result
.
ValidationErrors
.
FirstOrDefault
().
ErrorMessage
,
statusCode
:
401
);
return
HandleResult
(
_mapper
.
Map
<
Result
<
AuthenticationResponse
>>(
result
));
}
[
HttpPost
(
"Register"
)]
public
async
Task
<
IActionResult
>
Register
([
FromBody
]
RegisterRequest
registerRequest
)
{
...
...
PSManagement.Api/Controllers/Customers/CustomersController.cs
View file @
57363ef1
...
...
@@ -23,7 +23,7 @@ using PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo;
namespace
PSManagement.Api.Controllers.Customers
{
[
Route
(
"api/[controller]"
)]
//
[Authorize]
[
Authorize
]
public
class
CustomersController
:
APIController
{
private
readonly
IMediator
_sender
;
...
...
@@ -42,7 +42,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpGet
(
"{id}"
)]
...
...
@@ -53,7 +53,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
...
...
@@ -69,13 +69,13 @@ namespace PSManagement.Api.Controllers.Customers
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
response
));
}
else
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -88,7 +88,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -114,7 +114,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -125,7 +125,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
PSManagement.Api/Controllers/Employees/EmployeesController.cs
View file @
57363ef1
...
...
@@ -47,7 +47,7 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
EmployeeResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
EmployeeResponse
>>(
result
));
}
[
HttpGet
(
"ByFilter"
)]
...
...
@@ -57,37 +57,37 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
}
[
HttpGet
]
public
async
Task
<
IActionResult
>
GetAll
([
FromQuery
]
GetAvailableEmployeesRequest
request
)
[
HttpGet
(
"Available"
)
]
public
async
Task
<
IActionResult
>
GetAll
Available
([
FromQuery
]
GetAvailableEmployeesRequest
request
)
{
GetAvailableEmployeesQuery
query
=
_mapper
.
Map
<
GetAvailableEmployeesQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
}
[
Http
Pos
t
(
"EmployeeParticipations"
)]
public
async
Task
<
IActionResult
>
GetEmployeeParticipations
([
From
Form
]
GetEmployeeParticipationRequest
request
)
[
Http
Ge
t
(
"EmployeeParticipations"
)]
public
async
Task
<
IActionResult
>
GetEmployeeParticipations
([
From
Query
]
GetEmployeeParticipationRequest
request
)
{
var
command
=
_mapper
.
Map
<
GetEmployeeParticipationQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeParticipateResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeParticipateResponse
>>>(
result
));
}
[
Http
Pos
t
(
"TrackHistory"
)]
[
Http
Ge
t
(
"TrackHistory"
)]
public
async
Task
<
IActionResult
>
GetEmployeeTrackHistory
([
FromForm
]
GetEmployeeTrackHistoryRequest
request
)
{
var
command
=
_mapper
.
Map
<
GetEmployeeTrackHistoryQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeTrackResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeTrackResponse
>>>(
result
));
}
...
...
@@ -108,7 +108,7 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
PSManagement.Api/Controllers/FinancialSpends/FinancialSpendsController.cs
View file @
57363ef1
...
...
@@ -45,13 +45,13 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
query
=
new
GetFinancialSpendItemByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
FinancialSpendingResponse
>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>
>(
response
));
}
else
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
...
@@ -63,7 +63,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>>(
result
));
;
return
HandleResult
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>>(
result
));
;
}
[
HttpGet
(
"GetByProject"
)]
...
...
@@ -73,7 +73,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
FinancialSpendingResponse
>>>(
result
));
;
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
FinancialSpendingResponse
>>>(
result
));
;
}
[
HttpDelete
(
"{id}"
)]
...
...
@@ -87,7 +87,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
;
return
HandleResult
(
result
);
;
}
[
HttpPut
(
"{id}"
)]
...
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
;
return
HandleResult
(
result
);
;
}
}
...
...
PSManagement.Api/Controllers/Projects/ProjectsController.cs
View file @
57363ef1
...
...
@@ -53,7 +53,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -64,7 +64,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
}
[
HttpGet
(
"ByProjectManager"
)]
...
...
@@ -74,7 +74,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
}
[
HttpGet
(
"GetParticipants/{id}"
)]
...
...
@@ -84,7 +84,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeParticipateResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeParticipateResponse
>>>(
result
));
}
...
...
@@ -95,7 +95,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -106,7 +106,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -117,7 +117,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -128,7 +128,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
#
region
project
state
operations
...
...
@@ -140,7 +140,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
(
"CancelProject/{id}"
)]
...
...
@@ -154,7 +154,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -168,7 +168,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -181,7 +181,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
result
));
}
...
...
@@ -197,12 +197,12 @@ namespace PSManagement.Api.Controllers.Projects
var
query
=
new
GetProjectByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
response
));
}
else
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -213,7 +213,7 @@ namespace PSManagement.Api.Controllers.Projects
{
var
command
=
_mapper
.
Map
<
AddAttachmentCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpGet
(
"Attachments/{id}"
)]
...
...
@@ -222,7 +222,7 @@ namespace PSManagement.Api.Controllers.Projects
var
query
=
_mapper
.
Map
<
GetProjectAttachmentsQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
AttachmentReponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
AttachmentReponse
>>>(
result
));
}
...
...
PSManagement.Api/Controllers/Roles/RolesController.cs
View file @
57363ef1
...
...
@@ -32,7 +32,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
GetRoleByIdAsync
(
int
id
)
{
var
getRolesById
=
await
_roleService
.
GetRoleByIdAsync
(
id
);
return
Ok
(
getRolesById
);
return
HandleResult
(
getRolesById
);
}
[
Authorize
(
Roles
=
"Admin"
)]
...
...
@@ -40,7 +40,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
CreateRoleAsync
(
string
roleName
)
{
var
roleCreated
=
await
_roleService
.
CreateRoleAsync
(
roleName
);
return
Ok
(
roleCreated
);
return
HandleResult
(
roleCreated
);
}
[
Authorize
(
Roles
=
"Admin"
)]
...
...
@@ -48,15 +48,15 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
DeleteRoleAsync
(
int
id
)
{
var
deleteRole
=
await
_roleService
.
DeleteRoleAsync
(
id
);
return
Ok
(
deleteRole
);
return
HandleResult
(
deleteRole
);
}
[
Authorize
(
Roles
=
"Admin"
)]
[
HttpPut
(
"Edit/{id}"
)]
public
async
Task
<
ActionResult
>
UpdateRoleAsync
(
int
id
,
string
roleName
)
public
async
Task
<
I
ActionResult
>
UpdateRoleAsync
(
int
id
,
string
roleName
)
{
var
updateRole
=
await
_roleService
.
UpdateRole
(
id
,
roleName
);
return
Ok
(
updateRole
);
return
HandleResult
(
updateRole
);
}
}
}
PSManagement.Api/Controllers/Roles/UserRolesController.cs
View file @
57363ef1
...
...
@@ -23,22 +23,22 @@ namespace PSManagement.Api.Controllers.Roles
}
[
HttpGet
(
"GetUserRolesAsync"
)]
public
async
Task
<
ActionResult
>
GetUserRolesAsync
(
string
email
)
public
async
Task
<
I
ActionResult
>
GetUserRolesAsync
(
string
email
)
{
var
userRoles
=
await
_userRoleService
.
GetUserRolesAsync
(
email
);
return
Ok
(
userRoles
);
return
HandleResult
(
userRoles
);
}
[
Authorize
(
Roles
=
"Admin"
)]
[
HttpPost
(
"AssignUserToRoles"
)]
public
async
Task
<
ActionResult
>
AssignUserToRolesAsync
(
string
email
,
string
roleName
)
public
async
Task
<
I
ActionResult
>
AssignUserToRolesAsync
(
string
email
,
string
roleName
)
{
var
roleAssigned
=
await
_userRoleService
.
AssignUserToRole
(
email
,
roleName
);
return
Ok
(
roleAssigned
);
return
HandleResult
(
roleAssigned
);
}
[
HttpGet
(
"IsInRole"
)]
public
async
Task
<
ActionResult
>
IsInRoleAsync
(
int
id
,
string
role
)
public
async
Task
<
I
ActionResult
>
IsInRoleAsync
(
int
id
,
string
role
)
{
var
IsInRole
=
await
_userRoleService
.
IsInRoleAsync
(
id
,
role
);
return
Ok
(
IsInRole
);
...
...
@@ -50,7 +50,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
RemoveUserFromRole
(
string
email
,
string
roleName
)
{
var
deleteUserFromRole
=
await
_userRoleService
.
RemoveUserFromRole
(
email
,
roleName
);
return
Ok
(
deleteUserFromRole
);
return
HandleResult
(
deleteUserFromRole
);
}
...
...
PSManagement.Api/Controllers/Steps/StepsController.cs
View file @
57363ef1
...
...
@@ -38,7 +38,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
StepResponse
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpGet
(
"ByProject"
)]
...
...
@@ -48,20 +48,20 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPut
(
"{id}"
)]
public
async
Task
<
IActionResult
>
PutChangeStepWeight
(
ChangeStepWeightRequest
request
,[
FromRoute
]
int
id
)
{
if
(
request
.
StepId
!=
id
)
{
return
Ok
(
Result
.
NotFound
(
"the step not found"
));
return
HandleResult
(
Result
.
NotFound
(
"the step not found"
));
}
var
query
=
_mapper
.
Map
<
ChangeStepWeightCommand
>(
request
);
;
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -72,7 +72,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPut
]
...
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpDelete
(
"{id}"
)]
...
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
}
PSManagement.Api/Controllers/Tracks/TracksController.cs
View file @
57363ef1
...
...
@@ -41,7 +41,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
TrackResponse
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpGet
(
"GetStepsTrack{id}"
)]
...
...
@@ -51,7 +51,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpGet
(
"GetEmployeesTrack{id}"
)]
...
...
@@ -61,7 +61,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
@@ -72,7 +72,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
TrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
(
"AddStepTrack"
)]
...
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
(
"AddEmployeeTrack"
)]
...
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
(
"CompleteTrack"
)]
...
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
(
"RemoveTrack"
)]
...
...
@@ -112,7 +112,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPost
]
...
...
@@ -128,13 +128,13 @@ namespace PSManagement.Api.Controllers.Tracks
var
query
=
new
GetTrackByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
TrackResponse
>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
TrackResponse
>
>(
response
));
}
else
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
...
@@ -146,7 +146,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
[
HttpPut
(
"UpdateStepTrack"
)]
public
async
Task
<
IActionResult
>
PutStepTrack
(
UpdateStepTrackRequest
request
)
...
...
@@ -155,7 +155,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
...
...
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
View file @
57363ef1
using
AutoMapper
;
using
PSManagement.Application.Contracts.Authentication
;
using
PSManagement.Application.Customers.Common
;
using
PSManagement.Application.Customers.UseCases.Commands.AddContactInfo
;
using
PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
;
...
...
@@ -13,6 +14,7 @@ using PSManagement.Application.Projects.UseCases.Commands.CreateProject;
using
PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
;
using
PSManagement.Application.Projects.UseCases.Queries.ListAllProject
;
using
PSManagement.Application.Tracks.Common
;
using
PSManagement.Contracts.Authentication
;
using
PSManagement.Contracts.Customers.Requests
;
using
PSManagement.Contracts.Customers.Responses
;
using
PSManagement.Contracts.Projects.Requests
;
...
...
@@ -41,7 +43,8 @@ namespace PSManagement.Api.Mappers
CreateMap
<
IEnumerable
<
CustomerResponse
>,
ListCustomersResponse
>()
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
}
}
public
class
ProjectMapperConfiguration
:
Profile
...
...
PSManagement.Application/Projects/UseCases/Commands/AddParticipant/AddParticipantCommandHandler.cs
View file @
57363ef1
...
...
@@ -49,7 +49,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddParticipant
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
else
{
if
(
project
.
EmployeeParticipates
.
Where
(
e
=>
e
.
Id
==
request
.
ParticipantId
).
FirstOrDefault
()
is
not
null
)
if
(
project
.
EmployeeParticipates
.
Where
(
e
=>
e
.
Employee
Id
==
request
.
ParticipantId
).
FirstOrDefault
()
is
not
null
)
{
return
Result
.
Invalid
(
ProjectsErrors
.
ParticipantExistError
);
...
...
PSManagement.Application/Steps/UseCases/Queries/GetStepsByProject/GetStepsByProjectQueryHandler.cs
View file @
57363ef1
...
...
@@ -35,6 +35,7 @@ namespace PSManagement.Application.Steps.UseCases.Queries.GetStepsByProject
_specification
.
ApplyPaging
((
pageNumber
-
1
)
*
pageSize
,
pageSize
);
_specification
.
Criteria
=
p
=>
p
.
ProjectId
==
request
.
ProjectId
;
var
steps
=
await
_stepsRepository
.
ListAsync
(
_specification
);
return
Result
.
Success
(
_mapper
.
Map
<
IEnumerable
<
StepDTO
>>(
steps
));
...
...
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