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
7fd9449c
Commit
7fd9449c
authored
Aug 15, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add step controller and financial spend contoller
parent
3604a56e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
7 deletions
+189
-7
FinancialSpendsController.cs
.../Controllers/FinancialSpends/FinancialSpendsController.cs
+95
-0
StepsController.cs
PSManagement.Api/Controllers/Steps/StepsController.cs
+85
-1
DependencyInjection.cs
PSManagement.Api/DI/DependencyInjection.cs
+7
-4
MappersConfigurations.cs
PSManagement.Api/Mappers/MappersConfigurations.cs
+2
-2
No files found.
PSManagement.Api/Controllers/FinancialSpends/FinancialSpendsController.cs
0 → 100644
View file @
7fd9449c
using
Ardalis.Result
;
using
AutoMapper
;
using
MediatR
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
PSManagement.Api.Controllers.ApiBase
;
using
PSManagement.Application.FinancialSpends.UseCases.Commands.CreateFinancialSpendItem
;
using
PSManagement.Application.FinancialSpends.UseCases.Commands.RemoveFinancialSpendingItem
;
using
PSManagement.Application.FinancialSpends.UseCases.Commands.UpateFinancialSpendingItem
;
using
PSManagement.Application.FinancialSpends.UseCases.Queries.GetFinancialSpendingById
;
using
PSManagement.Application.FinancialSpends.UseCases.Queries.GetFinancialSpendingByProject
;
using
PSManagement.Contracts.FinancialSpends.Requests
;
using
PSManagement.Contracts.Projects.Response
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
PSManagement.Api.Controllers.FinancialSpends
{
[
Route
(
"api/[controller]"
)]
[
ApiController
]
public
class
FinancialSpendsController
:
APIController
{
private
readonly
IMediator
_sender
;
private
readonly
IMapper
_mapper
;
public
FinancialSpendsController
(
IMapper
mapper
,
IMediator
sender
)
{
_mapper
=
mapper
;
_sender
=
sender
;
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
Post
(
CreateFinancialSpendItemRequest
request
)
{
var
query
=
_mapper
.
Map
<
CreateFinancialSpendItemCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
}
[
HttpGet
]
public
async
Task
<
IActionResult
>
Get
(
[
FromQuery
]
GetFinancialSpendItemByIdRequest
request
)
{
var
query
=
_mapper
.
Map
<
GetFinancialSpendItemByIdQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
FinancialSpendingResponse
>>(
result
));
;
}
[
HttpGet
(
"GetByProject"
)]
public
async
Task
<
IActionResult
>
GetByProject
([
FromQuery
]
GetFinancialSpendItemByProjecRequest
request
)
{
var
query
=
_mapper
.
Map
<
GetFinancialSpendItemByProjectQuery
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
_mapper
.
Map
<
Result
<
IEnumerable
<
FinancialSpendingResponse
>>>(
result
));
;
}
[
HttpDelete
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Delete
(
RemoveFinancialSpendItemRequest
request
,[
FromRoute
]
int
id
)
{
if
(
id
!=
request
.
Id
)
{
Result
.
Conflict
();
}
var
query
=
_mapper
.
Map
<
RemoveFinancialSpendItemCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
;
}
[
HttpPut
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Put
(
UpdateFinancialSpendItemRequest
request
,
[
FromRoute
]
int
id
)
{
if
(
id
!=
request
.
Id
)
{
Result
.
Conflict
();
}
var
query
=
_mapper
.
Map
<
UpdateFinancialSpendItemCommand
>(
request
);
var
result
=
await
_sender
.
Send
(
query
);
return
Ok
(
result
);
;
}
}
}
PSManagement.Api/Controllers/Steps/StepsController.cs
View file @
7fd9449c
using
Microsoft.AspNetCore.Http
;
using
Ardalis.Result
;
using
AutoMapper
;
using
MediatR
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
PSManagement.Api.Controllers.ApiBase
;
using
PSManagement.Api.Controllers.ApiBase
;
using
PSManagement.Application.Steps.UseCases.Commands.ChangeStepWeight
;
using
PSManagement.Application.Steps.UseCases.Commands.RemoveStep
;
using
PSManagement.Application.Steps.UseCases.Commands.UpdateCompletionRatio
;
using
PSManagement.Application.Steps.UseCases.Queries.GetStepById
;
using
PSManagement.Application.Steps.UseCases.Queries.GetStepsByProject
;
using
PSManagement.Application.Steps.UseCases.Queries.GetStepTrackHistory
;
using
PSManagement.Contracts.Projects.Response
;
using
PSManagement.Contracts.Steps.Requests
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
...
@@ -11,5 +22,78 @@ namespace PSManagement.Api.Controllers.Steps
...
@@ -11,5 +22,78 @@ namespace PSManagement.Api.Controllers.Steps
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
public
class
StepsController
:
APIController
public
class
StepsController
:
APIController
{
{
private
readonly
IMapper
_mapper
;
private
readonly
IMediator
_sender
;
public
StepsController
(
IMediator
sender
,
IMapper
mapper
)
{
_sender
=
sender
;
_mapper
=
mapper
;
}
[
HttpGet
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Get
(
int
id
)
{
var
query
=
new
GetStepByIdQuery
(
id
)
;
var
result
=
_mapper
.
Map
<
Result
<
StepResponse
>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpGet
(
"ByProject"
)]
public
async
Task
<
IActionResult
>
GetByProject
(
GetStepsByProjectRequest
request
)
{
GetStepsByProjectQuery
query
=
_mapper
.
Map
<
GetStepsByProjectQuery
>(
request
);
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpPost
(
"{id}"
)]
public
async
Task
<
IActionResult
>
ChangeStepWeight
(
ChangeStepWeightRequest
request
,[
FromRoute
]
int
id
)
{
if
(
request
.
StepId
!=
id
)
{
return
Ok
(
Result
.
NotFound
(
"the step not found"
));
}
var
query
=
_mapper
.
Map
<
ChangeStepWeightCommand
>(
request
);
;
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpGet
(
"StepTrackHistory"
)]
public
async
Task
<
IActionResult
>
Get
(
GetStepTrackHistoryRequest
request
)
{
var
query
=
_mapper
.
Map
<
GetStepTrackHistoryQuery
>(
request
);
var
result
=
_mapper
.
Map
<
Result
<
IEnumerable
<
StepTrackResponse
>>>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpPost
]
public
async
Task
<
IActionResult
>
UpdateCompleteionRatio
(
UpdateCompletionRatioRequest
request
)
{
var
query
=
_mapper
.
Map
<
UpdateCompletionRatioCommand
>(
request
);
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
[
HttpDelete
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Delete
([
FromRoute
]
int
id
)
{
var
query
=
new
RemoveStepCommand
(
id
);
var
result
=
_mapper
.
Map
<
Result
>(
await
_sender
.
Send
(
query
));
return
Ok
(
result
);
}
}
}
}
}
PSManagement.Api/DI/DependencyInjection.cs
View file @
7fd9449c
...
@@ -21,10 +21,13 @@ namespace PSManagement.Api.DI
...
@@ -21,10 +21,13 @@ namespace PSManagement.Api.DI
services
.
AddApiCors
();
services
.
AddApiCors
();
services
.
AddScoped
<
Mapper
>();
services
.
AddScoped
<
Mapper
>();
services
.
AddAutoMapper
(
typeof
(
CustomerMapperConfiguration
),
services
.
AddAutoMapper
(
cfg
=>
{
typeof
(
ProjectMapperConfiguration
),
typeof
(
MapperConfigurations
));
cfg
.
AddProfile
<
CustomerMapperConfiguration
>();
cfg
.
AddProfile
<
ProjectMapperConfiguration
>();
cfg
.
AddProfile
<
MappersConfigurations
>();
});
return
services
;
return
services
;
}
}
...
...
PSManagement.Api/Mappers/MapperConfigurations.cs
→
PSManagement.Api/Mappers/Mapper
s
Configurations.cs
View file @
7fd9449c
...
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
...
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
namespace
PSManagement.Api.Mappers
namespace
PSManagement.Api.Mappers
{
{
public
class
MapperConfigurations
:
Profile
public
class
Mapper
s
Configurations
:
Profile
{
{
public
MapperConfigurations
()
public
Mapper
s
Configurations
()
{
{
CreateMap
(
typeof
(
Result
<>),
typeof
(
Result
<>)).
ConvertUsing
(
typeof
(
ResultToResultConverter
<,>));
CreateMap
(
typeof
(
Result
<>),
typeof
(
Result
<>)).
ConvertUsing
(
typeof
(
ResultToResultConverter
<,>));
}
}
...
...
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