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
7e7abea2
Commit
7e7abea2
authored
Aug 26, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor DI
parent
22786e30
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
51 deletions
+97
-51
DependencyInjection.cs
PSManagement.Api/DI/DependencyInjection.cs
+37
-10
CustomerMapperConfiguration.cs
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
+0
-37
EmployeeMapperConfiguration.cs
PSManagement.Api/Mappers/EmployeeMapperConfiguration.cs
+18
-0
ProjectMapperConfiguration.cs
PSManagement.Api/Mappers/ProjectMapperConfiguration.cs
+38
-0
PSManagement.Api.csproj
PSManagement.Api/PSManagement.Api.csproj
+4
-0
Startup.cs
PSManagement.Api/Startup.cs
+0
-4
No files found.
PSManagement.Api/DI/DependencyInjection.cs
View file @
7e7abea2
...
@@ -14,24 +14,28 @@ namespace PSManagement.Api.DI
...
@@ -14,24 +14,28 @@ namespace PSManagement.Api.DI
{
{
public
static
IServiceCollection
AddAPI
(
this
IServiceCollection
services
)
public
static
IServiceCollection
AddAPI
(
this
IServiceCollection
services
)
{
{
services
.
AddControllers
();
services
.
AddApiSwagger
();
services
.
AddApiSwagger
()
.
AddApiCors
()
.
AddMapper
()
.
AddMyControllers
();
services
.
AddApiCors
();
return
services
;
}
services
.
AddScoped
<
Mapper
>();
#
region
Configure
controllers
private
static
IServiceCollection
AddMyControllers
(
this
IServiceCollection
services
)
{
services
.
AddAutoMapper
(
cfg
=>
{
services
.
AddControllers
()
cfg
.
AddProfile
<
CustomerMapperConfiguration
>();
.
AddApplicationPart
(
Presentation
.
AssemblyReference
.
Assembly
);
cfg
.
AddProfile
<
ProjectMapperConfiguration
>();
cfg
.
AddProfile
<
MappersConfigurations
>();
});
return
services
;
return
services
;
}
}
#
endregion
Configure
controllers
#
region
Api
Docs
Swagger
private
static
IServiceCollection
AddApiSwagger
(
this
IServiceCollection
services
)
private
static
IServiceCollection
AddApiSwagger
(
this
IServiceCollection
services
)
{
{
...
@@ -65,7 +69,9 @@ namespace PSManagement.Api.DI
...
@@ -65,7 +69,9 @@ namespace PSManagement.Api.DI
return
services
;
return
services
;
}
}
#
endregion
Api
Docs
Swagger
#
region
Cors
private
static
IServiceCollection
AddApiCors
(
this
IServiceCollection
services
)
private
static
IServiceCollection
AddApiCors
(
this
IServiceCollection
services
)
{
{
services
.
AddCors
(
options
=>
services
.
AddCors
(
options
=>
...
@@ -83,6 +89,27 @@ namespace PSManagement.Api.DI
...
@@ -83,6 +89,27 @@ namespace PSManagement.Api.DI
return
services
;
return
services
;
}
}
#
endregion
Cors
#
region
Mappers
private
static
IServiceCollection
AddMapper
(
this
IServiceCollection
services
)
{
services
.
AddScoped
<
Mapper
>();
services
.
AddAutoMapper
(
cfg
=>
{
cfg
.
AddProfile
<
CustomerMapperConfiguration
>();
cfg
.
AddProfile
<
ProjectMapperConfiguration
>();
cfg
.
AddProfile
<
MappersConfigurations
>();
cfg
.
AddProfile
<
EmployeeMapperConfiguration
>();
});
return
services
;
}
#
endregion
Mappers
}
}
...
...
PSManagement.Api/Mappers/CustomerMapperConfiguration.cs
View file @
7e7abea2
...
@@ -4,22 +4,9 @@ using PSManagement.Application.Customers.Common;
...
@@ -4,22 +4,9 @@ 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
;
using
PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
;
using
PSManagement.Application.Customers.UseCases.Commands.UpdateCustomer
;
using
PSManagement.Application.Employees.Common
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Application.Projects.UseCases.Commands.AddParticipant
;
using
PSManagement.Application.Projects.UseCases.Commands.AddProjectStep
;
using
PSManagement.Application.Projects.UseCases.Commands.ApproveProject
;
using
PSManagement.Application.Projects.UseCases.Commands.ChangeProjectTeamLeader
;
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.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.Response
;
using
PSManagement.Contracts.Tracks.Response
;
using
PSManagement.SharedKernel.Utilities
;
using
PSManagement.SharedKernel.Utilities
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -47,28 +34,4 @@ namespace PSManagement.Api.Mappers
...
@@ -47,28 +34,4 @@ namespace PSManagement.Api.Mappers
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
}
}
}
}
public
class
ProjectMapperConfiguration
:
Profile
{
public
ProjectMapperConfiguration
()
{
CreateMap
<
CreateProjectRequest
,
CreateProjectCommand
>().
ReverseMap
();
CreateMap
<
ListAllProjectsRequest
,
ListAllProjectsQuery
>().
ReverseMap
();
CreateMap
<
ApproveProjectRequest
,
ApproveProjectCommand
>().
ReverseMap
();
CreateMap
<
AddParticipantRequest
,
AddParticipantCommand
>().
ReverseMap
();
CreateMap
<
AddProjectStepRequest
,
AddProjectStepCommand
>().
ReverseMap
();
CreateMap
<
ChangeProjectTeamLeaderRequest
,
ChangeProjectTeamLeaderCommand
>().
ReverseMap
();
CreateMap
<
RemoveParticipantRequest
,
RemoveParticipantCommand
>().
ReverseMap
();
CreateMap
<
ProjectDTO
,
ProjectResponse
>().
ReverseMap
();
CreateMap
<
GetProjectsByProjectManagerRequest
,
GetProjectsByFilterQuery
>().
ConstructUsing
(
s
=>
new
GetProjectsByFilterQuery
(
null
,
null
,
null
,
null
,
s
.
ProjectManagerId
,
null
,
null
,
null
)
);
CreateMap
<
EmployeeResponse
,
EmployeeDTO
>().
ReverseMap
();
CreateMap
<
EmployeeParticipateResponse
,
EmployeeParticipateDTO
>().
ReverseMap
();
CreateMap
<
TrackDTO
,
TrackResponse
>().
ReverseMap
();
}
}
}
}
PSManagement.Api/Mappers/EmployeeMapperConfiguration.cs
0 → 100644
View file @
7e7abea2
using
AutoMapper
;
using
PSManagement.Application.Employees.Common
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Contracts.Projects.Response
;
namespace
PSManagement.Api.Mappers
{
public
class
EmployeeMapperConfiguration
:
Profile
{
public
EmployeeMapperConfiguration
()
{
CreateMap
<
EmployeeResponse
,
EmployeeDTO
>().
ReverseMap
();
CreateMap
<
EmployeeParticipateResponse
,
EmployeeParticipateDTO
>().
ReverseMap
();
}
}
}
PSManagement.Api/Mappers/ProjectMapperConfiguration.cs
0 → 100644
View file @
7e7abea2
using
AutoMapper
;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Application.Projects.UseCases.Commands.AddParticipant
;
using
PSManagement.Application.Projects.UseCases.Commands.AddProjectStep
;
using
PSManagement.Application.Projects.UseCases.Commands.ApproveProject
;
using
PSManagement.Application.Projects.UseCases.Commands.ChangeProjectTeamLeader
;
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.Projects.Requests
;
using
PSManagement.Contracts.Projects.Response
;
using
PSManagement.Contracts.Tracks.Response
;
namespace
PSManagement.Api.Mappers
{
public
class
ProjectMapperConfiguration
:
Profile
{
public
ProjectMapperConfiguration
()
{
CreateMap
<
CreateProjectRequest
,
CreateProjectCommand
>().
ReverseMap
();
CreateMap
<
ListAllProjectsRequest
,
ListAllProjectsQuery
>().
ReverseMap
();
CreateMap
<
ApproveProjectRequest
,
ApproveProjectCommand
>().
ReverseMap
();
CreateMap
<
AddParticipantRequest
,
AddParticipantCommand
>().
ReverseMap
();
CreateMap
<
AddProjectStepRequest
,
AddProjectStepCommand
>().
ReverseMap
();
CreateMap
<
ChangeProjectTeamLeaderRequest
,
ChangeProjectTeamLeaderCommand
>().
ReverseMap
();
CreateMap
<
RemoveParticipantRequest
,
RemoveParticipantCommand
>().
ReverseMap
();
CreateMap
<
ProjectDTO
,
ProjectResponse
>().
ReverseMap
();
CreateMap
<
GetProjectsByProjectManagerRequest
,
GetProjectsByFilterQuery
>().
ConstructUsing
(
s
=>
new
GetProjectsByFilterQuery
(
null
,
null
,
null
,
null
,
s
.
ProjectManagerId
,
null
,
null
,
null
)
);
CreateMap
<
TrackDTO
,
TrackResponse
>().
ReverseMap
();
}
}
}
PSManagement.Api/PSManagement.Api.csproj
View file @
7e7abea2
...
@@ -26,4 +26,8 @@
...
@@ -26,4 +26,8 @@
<ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" />
<ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<Folder Include="Middleware\ExceptionHandling\" />
</ItemGroup>
</Project>
</Project>
PSManagement.Api/Startup.cs
View file @
7e7abea2
...
@@ -31,16 +31,12 @@ namespace PSManagement.Api
...
@@ -31,16 +31,12 @@ namespace PSManagement.Api
public
void
ConfigureServices
(
IServiceCollection
services
)
public
void
ConfigureServices
(
IServiceCollection
services
)
{
{
// adding dependency injection
// adding dependency injection
services
services
.
AddAPI
()
.
AddAPI
()
.
AddPresentation
()
.
AddPresentation
()
.
AddApplication
()
.
AddApplication
()
.
AddPersistence
(
Configuration
)
.
AddPersistence
(
Configuration
)
.
AddInfrastructure
(
Configuration
);
.
AddInfrastructure
(
Configuration
);
services
.
AddControllers
()
.
AddApplicationPart
(
Presentation
.
AssemblyReference
.
Assembly
);
}
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
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