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
9ae05f5b
Unverified
Commit
9ae05f5b
authored
Aug 17, 2024
by
Almouhannad Hafez
Committed by
GitHub
Aug 17, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from Almouhannad/B_Add-MediatR-and-CQRS-bases
B add mediat r and cqrs bases
parents
ead3c9e3
4c0a6b16
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
96 additions
and
11 deletions
+96
-11
API.csproj
Clinics.Backend/API/API.csproj
+1
-0
Program.cs
Clinics.Backend/API/Program.cs
+19
-7
ICommand.cs
...ackend/Application/Abstractions/CQRS/Commands/ICommand.cs
+13
-0
ICommandHandler.cs
...Application/Abstractions/CQRS/Commands/ICommandHandler.cs
+16
-0
IQuery.cs
...s.Backend/Application/Abstractions/CQRS/Queries/IQuery.cs
+12
-0
IQueryHandler.cs
...nd/Application/Abstractions/CQRS/Queries/IQueryHandler.cs
+9
-0
Application.csproj
Clinics.Backend/Application/Application.csproj
+4
-0
AssemblyReference.cs
Clinics.Backend/Application/AssemblyReference.cs
+8
-0
AssemblyReference.cs
Clinics.Backend/Persistence/AssemblyReference.cs
+8
-0
AssemblyReference.cs
Clinics.Backend/Presentation/AssemblyReference.cs
+6
-4
No files found.
Clinics.Backend/API/API.csproj
View file @
9ae05f5b
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="12.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<PrivateAssets>all</PrivateAssets>
...
...
Clinics.Backend/API/Program.cs
View file @
9ae05f5b
using
API.Options.Database
;
using
API.Options.Database
;
using
Domain.Repositories.Base
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
using
Persistence.Context
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
var
builder
=
WebApplication
.
CreateBuilder
(
args
);
var
builder
=
WebApplication
.
CreateBuilder
(
args
);
...
@@ -32,15 +30,29 @@ builder.Services.AddDbContext<ClinicsDbContext>(
...
@@ -32,15 +30,29 @@ builder.Services.AddDbContext<ClinicsDbContext>(
// Add services to the container.
// Add services to the container.
#region Link repositories
#region Link interfaces implemented in persistence
// AddTransient: Created on demand, every time they are requested, not shared across requests or components.
// Using Scrutor library
builder
.
Services
.
AddTransient
(
typeof
(
IRepository
<>),
typeof
(
Repositroy
<>));
builder
.
Services
.
Scan
(
selector
=>
selector
.
FromAssemblies
(
Persistence
.
AssemblyReference
.
Assembly
// Add other assemblies here
)
.
AddClasses
(
false
)
.
AsImplementedInterfaces
()
.
WithScopedLifetime
()
);
#endregion
#region Add MadiatR
builder
.
Services
.
AddMediatR
(
configuration
=>
configuration
.
RegisterServicesFromAssembly
(
Application
.
AssemblyReference
.
Assembly
));
#endregion
#endregion
#region Link controllers with presentation layer
#region Link controllers with presentation layer
var
presentationAssembly
=
typeof
(
Presentation
.
AssemblyReference
).
Assembly
;
builder
.
Services
.
AddControllers
()
builder
.
Services
.
AddControllers
()
.
AddApplicationPart
(
presentation
Assembly
);
.
AddApplicationPart
(
Presentation
.
AssemblyReference
.
Assembly
);
#endregion
#endregion
...
...
Clinics.Backend/Application/Abstractions/CQRS/Commands/ICommand.cs
0 → 100644
View file @
9ae05f5b
using
MediatR
;
namespace
Application.Abstractions.CQRS.Commands
;
// No response
public
interface
ICommand
:
IRequest
{
}
// With response
public
interface
ICommand
<
TResponse
>
:
IRequest
<
TResponse
>
{
}
Clinics.Backend/Application/Abstractions/CQRS/Commands/ICommandHandler.cs
0 → 100644
View file @
9ae05f5b
using
MediatR
;
namespace
Application.Abstractions.CQRS.Commands
;
// No response
public
interface
ICommandHandler
<
TCommand
>
:
IRequestHandler
<
TCommand
>
where
TCommand
:
ICommand
{
}
// With response
public
interface
ICommandHandler
<
TCommand
,
TResponse
>
:
IRequestHandler
<
TCommand
,
TResponse
>
where
TCommand
:
ICommand
<
TResponse
>
{
}
\ No newline at end of file
Clinics.Backend/Application/Abstractions/CQRS/Queries/IQuery.cs
0 → 100644
View file @
9ae05f5b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Application.Abstractions.CQRS.Queries
{
internal
interface
Interface1
{
}
}
Clinics.Backend/Application/Abstractions/CQRS/Queries/IQueryHandler.cs
0 → 100644
View file @
9ae05f5b
using
MediatR
;
namespace
Application.Abstractions.CQRS.Queries
;
public
interface
IQueryHandler
<
TQuery
,
TResponse
>
:
IRequestHandler
<
TQuery
,
TResponse
>
where
TQuery
:
IQuery
<
TResponse
>
{
}
Clinics.Backend/Application/Application.csproj
View file @
9ae05f5b
...
@@ -6,6 +6,10 @@
...
@@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
<Nullable>enable</Nullable>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="12.4.0" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
</ItemGroup>
...
...
Clinics.Backend/Application/AssemblyReference.cs
0 → 100644
View file @
9ae05f5b
using
System.Reflection
;
namespace
Application
;
public
class
AssemblyReference
{
public
static
readonly
Assembly
Assembly
=
typeof
(
AssemblyReference
).
Assembly
;
}
Clinics.Backend/Persistence/AssemblyReference.cs
0 → 100644
View file @
9ae05f5b
using
System.Reflection
;
namespace
Persistence
;
public
class
AssemblyReference
{
public
static
readonly
Assembly
Assembly
=
typeof
(
AssemblyReference
).
Assembly
;
}
Clinics.Backend/Presentation/AssemblyReference.cs
View file @
9ae05f5b
namespace
Presentation
using
System.Reflection
;
namespace
Presentation
;
public
class
AssemblyReference
{
{
public
class
AssemblyReference
public
static
readonly
Assembly
Assembly
=
typeof
(
AssemblyReference
).
Assembly
;
{
}
}
}
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