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
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -11,5 +13,18 @@ namespace PSManagement.Api.Controllers.ApiBase
...
@@ -11,5 +13,18 @@ namespace PSManagement.Api.Controllers.ApiBase
[
ApiController
]
[
ApiController
]
public
class
APIController
:
ControllerBase
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;
...
@@ -6,6 +6,7 @@ using PSManagement.Application.Contracts.Authentication;
using
PSManagement.Contracts.Authentication
;
using
PSManagement.Contracts.Authentication
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
AuthenticationResponse
=
PSManagement
.
Contracts
.
Authentication
.
AuthenticationResponse
;
using
AuthenticationResponse
=
PSManagement
.
Contracts
.
Authentication
.
AuthenticationResponse
;
using
AutoMapper
;
namespace
PSManagement.Api.Controllers.Authentication
namespace
PSManagement.Api.Controllers.Authentication
{
{
...
@@ -13,29 +14,23 @@ namespace PSManagement.Api.Controllers.Authentication
...
@@ -13,29 +14,23 @@ namespace PSManagement.Api.Controllers.Authentication
public
class
AuthenticationController
:
APIController
public
class
AuthenticationController
:
APIController
{
{
private
readonly
IAuthenticationService
_authenticationService
;
private
readonly
IAuthenticationService
_authenticationService
;
private
readonly
IMapper
_mapper
;
public
AuthenticationController
(
IAuthenticationService
authenticationService
)
public
AuthenticationController
(
IAuthenticationService
authenticationService
,
IMapper
mapper
)
{
{
_authenticationService
=
authenticationService
;
_authenticationService
=
authenticationService
;
_mapper
=
mapper
;
}
}
[
HttpPost
(
"Login"
)]
[
HttpPost
(
"Login"
)]
public
async
Task
<
IActionResult
>
Login
([
FromBody
]
LoginRequest
loginRequest
)
public
async
Task
<
IActionResult
>
Login
([
FromBody
]
LoginRequest
loginRequest
)
{
{
Result
<
AuthenticationResult
>
result
=
await
_authenticationService
.
Login
(
loginRequest
.
Email
,
loginRequest
.
PassWord
);
Result
<
AuthenticationResult
>
result
=
await
_authenticationService
.
Login
(
loginRequest
.
Email
,
loginRequest
.
PassWord
);
if
(
result
.
IsSuccess
)
{
return
HandleResult
(
_mapper
.
Map
<
Result
<
AuthenticationResponse
>>(
result
));
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
);
}
}
[
HttpPost
(
"Register"
)]
[
HttpPost
(
"Register"
)]
public
async
Task
<
IActionResult
>
Register
([
FromBody
]
RegisterRequest
registerRequest
)
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;
...
@@ -23,7 +23,7 @@ using PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo;
namespace
PSManagement.Api.Controllers.Customers
namespace
PSManagement.Api.Controllers.Customers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
//
[Authorize]
[
Authorize
]
public
class
CustomersController
:
APIController
public
class
CustomersController
:
APIController
{
{
private
readonly
IMediator
_sender
;
private
readonly
IMediator
_sender
;
...
@@ -42,7 +42,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -42,7 +42,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerResponse
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
CustomerResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpGet
(
"{id}"
)]
[
HttpGet
(
"{id}"
)]
...
@@ -53,7 +53,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -53,7 +53,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
}
}
[
HttpPost
]
[
HttpPost
]
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
...
@@ -69,13 +69,13 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -69,13 +69,13 @@ namespace PSManagement.Api.Controllers.Customers
var
response
=
await
_sender
.
Send
(
query
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
response
));
}
}
else
else
{
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -88,7 +88,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -88,7 +88,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -114,7 +114,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -114,7 +114,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -125,7 +125,7 @@ namespace PSManagement.Api.Controllers.Customers
...
@@ -125,7 +125,7 @@ namespace PSManagement.Api.Controllers.Customers
var
result
=
await
_sender
.
Send
(
command
);
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
...
@@ -47,7 +47,7 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
EmployeeResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
EmployeeResponse
>>(
result
));
}
}
[
HttpGet
(
"ByFilter"
)]
[
HttpGet
(
"ByFilter"
)]
...
@@ -57,37 +57,37 @@ namespace PSManagement.Api.Controllers.Employees
...
@@ -57,37 +57,37 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeResponse
>>>(
result
));
}
}
[
HttpGet
]
[
HttpGet
(
"Available"
)
]
public
async
Task
<
IActionResult
>
GetAll
([
FromQuery
]
GetAvailableEmployeesRequest
request
)
public
async
Task
<
IActionResult
>
GetAll
Available
([
FromQuery
]
GetAvailableEmployeesRequest
request
)
{
{
GetAvailableEmployeesQuery
query
=
_mapper
.
Map
<
GetAvailableEmployeesQuery
>(
request
);
GetAvailableEmployeesQuery
query
=
_mapper
.
Map
<
GetAvailableEmployeesQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
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"
)]
[
Http
Ge
t
(
"EmployeeParticipations"
)]
public
async
Task
<
IActionResult
>
GetEmployeeParticipations
([
From
Form
]
GetEmployeeParticipationRequest
request
)
public
async
Task
<
IActionResult
>
GetEmployeeParticipations
([
From
Query
]
GetEmployeeParticipationRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
GetEmployeeParticipationQuery
>(
request
);
var
command
=
_mapper
.
Map
<
GetEmployeeParticipationQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
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
)
public
async
Task
<
IActionResult
>
GetEmployeeTrackHistory
([
FromForm
]
GetEmployeeTrackHistoryRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
GetEmployeeTrackHistoryQuery
>(
request
);
var
command
=
_mapper
.
Map
<
GetEmployeeTrackHistoryQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
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
...
@@ -108,7 +108,7 @@ namespace PSManagement.Api.Controllers.Employees
var
result
=
await
_sender
.
Send
(
query
);
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
...
@@ -45,13 +45,13 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
query
=
new
GetFinancialSpendItemByIdQuery
(
result
.
Value
);
var
query
=
new
GetFinancialSpendItemByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
FinancialSpendingResponse
>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>
>(
response
));
}
}
else
else
{
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
}
}
...
@@ -63,7 +63,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
...
@@ -63,7 +63,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>>(
result
));
;
return
HandleResult
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>>(
result
));
;
}
}
[
HttpGet
(
"GetByProject"
)]
[
HttpGet
(
"GetByProject"
)]
...
@@ -73,7 +73,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
...
@@ -73,7 +73,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
FinancialSpendingResponse
>>>(
result
));
;
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
FinancialSpendingResponse
>>>(
result
));
;
}
}
[
HttpDelete
(
"{id}"
)]
[
HttpDelete
(
"{id}"
)]
...
@@ -87,7 +87,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
...
@@ -87,7 +87,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
;
return
HandleResult
(
result
);
;
}
}
[
HttpPut
(
"{id}"
)]
[
HttpPut
(
"{id}"
)]
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.FinancialSpends
var
result
=
await
_sender
.
Send
(
query
);
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
...
@@ -53,7 +53,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
await
_sender
.
Send
(
query
));
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
...
@@ -64,7 +64,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
IEnumerable
<
ProjectResponse
>>>(
result
));
}
}
[
HttpGet
(
"ByProjectManager"
)]
[
HttpGet
(
"ByProjectManager"
)]
...
@@ -74,7 +74,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -74,7 +74,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
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}"
)]
[
HttpGet
(
"GetParticipants/{id}"
)]
...
@@ -84,7 +84,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -84,7 +84,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
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
...
@@ -95,7 +95,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -106,7 +106,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -106,7 +106,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -117,7 +117,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -117,7 +117,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -128,7 +128,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -128,7 +128,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
#
region
project
state
operations
#
region
project
state
operations
...
@@ -140,7 +140,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -140,7 +140,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
(
"CancelProject/{id}"
)]
[
HttpPost
(
"CancelProject/{id}"
)]
...
@@ -154,7 +154,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -154,7 +154,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -168,7 +168,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -168,7 +168,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -181,7 +181,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -181,7 +181,7 @@ namespace PSManagement.Api.Controllers.Projects
var
result
=
await
_sender
.
Send
(
query
);
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
...
@@ -197,12 +197,12 @@ namespace PSManagement.Api.Controllers.Projects
var
query
=
new
GetProjectByIdQuery
(
result
.
Value
);
var
query
=
new
GetProjectByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
ProjectResponse
>>(
response
));
}
}
else
{
else
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -213,7 +213,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -213,7 +213,7 @@ namespace PSManagement.Api.Controllers.Projects
{
{
var
command
=
_mapper
.
Map
<
AddAttachmentCommand
>(
request
);
var
command
=
_mapper
.
Map
<
AddAttachmentCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpGet
(
"Attachments/{id}"
)]
[
HttpGet
(
"Attachments/{id}"
)]
...
@@ -222,7 +222,7 @@ namespace PSManagement.Api.Controllers.Projects
...
@@ -222,7 +222,7 @@ namespace PSManagement.Api.Controllers.Projects
var
query
=
_mapper
.
Map
<
GetProjectAttachmentsQuery
>(
request
);
var
query
=
_mapper
.
Map
<
GetProjectAttachmentsQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
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
...
@@ -32,7 +32,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
GetRoleByIdAsync
(
int
id
)
public
async
Task
<
IActionResult
>
GetRoleByIdAsync
(
int
id
)
{
{
var
getRolesById
=
await
_roleService
.
GetRoleByIdAsync
(
id
);
var
getRolesById
=
await
_roleService
.
GetRoleByIdAsync
(
id
);
return
Ok
(
getRolesById
);
return
HandleResult
(
getRolesById
);
}
}
[
Authorize
(
Roles
=
"Admin"
)]
[
Authorize
(
Roles
=
"Admin"
)]
...
@@ -40,7 +40,7 @@ namespace PSManagement.Api.Controllers.Roles
...
@@ -40,7 +40,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
CreateRoleAsync
(
string
roleName
)
public
async
Task
<
IActionResult
>
CreateRoleAsync
(
string
roleName
)
{
{
var
roleCreated
=
await
_roleService
.
CreateRoleAsync
(
roleName
);
var
roleCreated
=
await
_roleService
.
CreateRoleAsync
(
roleName
);
return
Ok
(
roleCreated
);
return
HandleResult
(
roleCreated
);
}
}
[
Authorize
(
Roles
=
"Admin"
)]
[
Authorize
(
Roles
=
"Admin"
)]
...
@@ -48,15 +48,15 @@ namespace PSManagement.Api.Controllers.Roles
...
@@ -48,15 +48,15 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
DeleteRoleAsync
(
int
id
)
public
async
Task
<
IActionResult
>
DeleteRoleAsync
(
int
id
)
{
{
var
deleteRole
=
await
_roleService
.
DeleteRoleAsync
(
id
);
var
deleteRole
=
await
_roleService
.
DeleteRoleAsync
(
id
);
return
Ok
(
deleteRole
);
return
HandleResult
(
deleteRole
);
}
}
[
Authorize
(
Roles
=
"Admin"
)]
[
Authorize
(
Roles
=
"Admin"
)]
[
HttpPut
(
"Edit/{id}"
)]
[
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
);
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
...
@@ -23,22 +23,22 @@ namespace PSManagement.Api.Controllers.Roles
}
}
[
HttpGet
(
"GetUserRolesAsync"
)]
[
HttpGet
(
"GetUserRolesAsync"
)]
public
async
Task
<
ActionResult
>
GetUserRolesAsync
(
string
email
)
public
async
Task
<
I
ActionResult
>
GetUserRolesAsync
(
string
email
)
{
{
var
userRoles
=
await
_userRoleService
.
GetUserRolesAsync
(
email
);
var
userRoles
=
await
_userRoleService
.
GetUserRolesAsync
(
email
);
return
Ok
(
userRoles
);
return
HandleResult
(
userRoles
);
}
}
[
Authorize
(
Roles
=
"Admin"
)]
[
Authorize
(
Roles
=
"Admin"
)]
[
HttpPost
(
"AssignUserToRoles"
)]
[
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
);
var
roleAssigned
=
await
_userRoleService
.
AssignUserToRole
(
email
,
roleName
);
return
Ok
(
roleAssigned
);
return
HandleResult
(
roleAssigned
);
}
}
[
HttpGet
(
"IsInRole"
)]
[
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
);
var
IsInRole
=
await
_userRoleService
.
IsInRoleAsync
(
id
,
role
);
return
Ok
(
IsInRole
);
return
Ok
(
IsInRole
);
...
@@ -50,7 +50,7 @@ namespace PSManagement.Api.Controllers.Roles
...
@@ -50,7 +50,7 @@ namespace PSManagement.Api.Controllers.Roles
public
async
Task
<
IActionResult
>
RemoveUserFromRole
(
string
email
,
string
roleName
)
public
async
Task
<
IActionResult
>
RemoveUserFromRole
(
string
email
,
string
roleName
)
{
{
var
deleteUserFromRole
=
await
_userRoleService
.
RemoveUserFromRole
(
email
,
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
...
@@ -38,7 +38,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
StepResponse
>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
StepResponse
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpGet
(
"ByProject"
)]
[
HttpGet
(
"ByProject"
)]
...
@@ -48,20 +48,20 @@ namespace PSManagement.Api.Controllers.Steps
...
@@ -48,20 +48,20 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepResponse
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPut
(
"{id}"
)]
[
HttpPut
(
"{id}"
)]
public
async
Task
<
IActionResult
>
PutChangeStepWeight
(
ChangeStepWeightRequest
request
,[
FromRoute
]
int
id
)
public
async
Task
<
IActionResult
>
PutChangeStepWeight
(
ChangeStepWeightRequest
request
,[
FromRoute
]
int
id
)
{
{
if
(
request
.
StepId
!=
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
query
=
_mapper
.
Map
<
ChangeStepWeightCommand
>(
request
);
;
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
@@ -72,7 +72,7 @@ namespace PSManagement.Api.Controllers.Steps
...
@@ -72,7 +72,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPut
]
[
HttpPut
]
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Steps
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpDelete
(
"{id}"
)]
[
HttpDelete
(
"{id}"
)]
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Steps
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Steps
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
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
...
@@ -41,7 +41,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
TrackResponse
>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
TrackResponse
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpGet
(
"GetStepsTrack{id}"
)]
[
HttpGet
(
"GetStepsTrack{id}"
)]
...
@@ -51,7 +51,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -51,7 +51,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpGet
(
"GetEmployeesTrack{id}"
)]
[
HttpGet
(
"GetEmployeesTrack{id}"
)]
...
@@ -61,7 +61,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -61,7 +61,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
EmployeeTrackResponse
>>>(
await
_sender
.
Send
(
query
));
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
...
@@ -72,7 +72,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
TrackResponse
>>>(
await
_sender
.
Send
(
query
));
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
TrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
(
"AddStepTrack"
)]
[
HttpPost
(
"AddStepTrack"
)]
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -82,7 +82,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
(
"AddEmployeeTrack"
)]
[
HttpPost
(
"AddEmployeeTrack"
)]
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -92,7 +92,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
var
result
=
_mapper
.
Map
<
Result
<
int
>>(
await
_sender
.
Send
(
command
));
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
(
"CompleteTrack"
)]
[
HttpPost
(
"CompleteTrack"
)]
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -102,7 +102,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
(
"RemoveTrack"
)]
[
HttpPost
(
"RemoveTrack"
)]
...
@@ -112,7 +112,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -112,7 +112,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPost
]
[
HttpPost
]
...
@@ -128,13 +128,13 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -128,13 +128,13 @@ namespace PSManagement.Api.Controllers.Tracks
var
query
=
new
GetTrackByIdQuery
(
result
.
Value
);
var
query
=
new
GetTrackByIdQuery
(
result
.
Value
);
var
response
=
await
_sender
.
Send
(
query
);
var
response
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
TrackResponse
>(
response
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
TrackResponse
>
>(
response
));
}
}
else
else
{
{
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
}
}
...
@@ -146,7 +146,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -146,7 +146,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
[
HttpPut
(
"UpdateStepTrack"
)]
[
HttpPut
(
"UpdateStepTrack"
)]
public
async
Task
<
IActionResult
>
PutStepTrack
(
UpdateStepTrackRequest
request
)
public
async
Task
<
IActionResult
>
PutStepTrack
(
UpdateStepTrackRequest
request
)
...
@@ -155,7 +155,7 @@ namespace PSManagement.Api.Controllers.Tracks
...
@@ -155,7 +155,7 @@ namespace PSManagement.Api.Controllers.Tracks
var
result
=
await
_sender
.
Send
(
command
);
var
result
=
await
_sender
.
Send
(
command
);
return
Ok
(
result
);
return
HandleResult
(
result
);
}
}
...
...
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
View file @
57363ef1
using
AutoMapper
;
using
AutoMapper
;
using
PSManagement.Application.Contracts.Authentication
;
using
PSManagement.Application.Customers.Common
;
using
PSManagement.Application.Customers.Common
;
using
PSManagement.Application.Customers.UseCases.Commands.AddContactInfo
;
using
PSManagement.Application.Customers.UseCases.Commands.AddContactInfo
;
using
PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
;
using
PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
;
...
@@ -13,6 +14,7 @@ using PSManagement.Application.Projects.UseCases.Commands.CreateProject;
...
@@ -13,6 +14,7 @@ using PSManagement.Application.Projects.UseCases.Commands.CreateProject;
using
PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
;
using
PSManagement.Application.Projects.UseCases.Commands.RemoveParticipant
;
using
PSManagement.Application.Projects.UseCases.Queries.ListAllProject
;
using
PSManagement.Application.Projects.UseCases.Queries.ListAllProject
;
using
PSManagement.Application.Tracks.Common
;
using
PSManagement.Application.Tracks.Common
;
using
PSManagement.Contracts.Authentication
;
using
PSManagement.Contracts.Customers.Requests
;
using
PSManagement.Contracts.Customers.Requests
;
using
PSManagement.Contracts.Customers.Responses
;
using
PSManagement.Contracts.Customers.Responses
;
using
PSManagement.Contracts.Projects.Requests
;
using
PSManagement.Contracts.Projects.Requests
;
...
@@ -41,7 +43,8 @@ namespace PSManagement.Api.Mappers
...
@@ -41,7 +43,8 @@ namespace PSManagement.Api.Mappers
CreateMap
<
IEnumerable
<
CustomerResponse
>,
ListCustomersResponse
>()
CreateMap
<
IEnumerable
<
CustomerResponse
>,
ListCustomersResponse
>()
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
}
}
}
}
public
class
ProjectMapperConfiguration
:
Profile
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
...
@@ -49,7 +49,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddParticipant
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
return
Result
.
Invalid
(
ProjectsErrors
.
InvalidEntryError
);
}
else
{
}
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
);
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
...
@@ -35,6 +35,7 @@ namespace PSManagement.Application.Steps.UseCases.Queries.GetStepsByProject
_specification
.
ApplyPaging
((
pageNumber
-
1
)
*
pageSize
,
pageSize
);
_specification
.
ApplyPaging
((
pageNumber
-
1
)
*
pageSize
,
pageSize
);
_specification
.
Criteria
=
p
=>
p
.
ProjectId
==
request
.
ProjectId
;
var
steps
=
await
_stepsRepository
.
ListAsync
(
_specification
);
var
steps
=
await
_stepsRepository
.
ListAsync
(
_specification
);
return
Result
.
Success
(
_mapper
.
Map
<
IEnumerable
<
StepDTO
>>(
steps
));
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