Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

WIP: Feature course registration #364

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<DockerLaunchBrowser>True</DockerLaunchBrowser>
<DockerServiceUrl>http://localhost:5102/swagger</DockerServiceUrl>
<DockerServiceName>enrolling.api</DockerServiceName>
<DockerServiceUrl>http://localhost:5103/swagger</DockerServiceUrl>
mahedee marked this conversation as resolved.
Show resolved Hide resolved
<DockerServiceName>courseregistration.api</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ services:
- "5102:80"
- "5581:5001"

courseregistration.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionStrings=Server=sql.data;Database=OpenCodeFoundation.CourseRegistrationDb;User Id=sa;Password=Pass@word
ports:
- "5103:80"
- "5582:5001"

webstatus:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionStrings=Server=sql.data;Database=OpenCodeFoundation.WebStatusDb;User Id=sa;Password=Pass@word
- HealthChecksUI__HealthChecks__0__Name=Enrolling HTTP Check
- HealthChecksUI__HealthChecks__0__Uri=http://enrolling.api/hc
- HealthChecksUI__HealthChecks__1__Name=CourseRegistration HTTP Check
- HealthChecksUI__HealthChecks__1__Uri=http://courseregistration.api/hc
ports:
- "5107:80"

Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ services:
depends_on:
- sql.data

courseregistration.api:
image: ${REGISTRY:-eschool}/courseregistration.api:${TAG:-latest}
build:
context: .
dockerfile: src/Services/CourseRegistration/CourseRegistration.API/Dockerfile
depends_on:
- sql.data

webstatus:
image: ${REGISTRY:-eschool}/webstatus:${TAG:-latest}
build:
Expand Down
91 changes: 86 additions & 5 deletions eSchool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,34 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebStatus", "src\Web\WebSta
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{74511F4E-FF9D-42C4-9531-A75C61270B73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry", "src\Libraries\OpenTelemetry\OpenTelemetry.csproj", "{7B410F3B-36E0-4853-9B4E-41D0CC2865B5}"
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry", "src\Libraries\OpenTelemetry\OpenTelemetry.csproj", "{7B410F3B-36E0-4853-9B4E-41D0CC2865B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGateways", "ApiGateways", "{256317ED-A2C8-48A0-9C6E-D6EB1F7D0BE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eSchool.GraphQL", "src\ApiGateways\eSchool.GraphQL\eSchool.GraphQL.csproj", "{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}"
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "eSchool.GraphQL", "src\ApiGateways\eSchool.GraphQL\eSchool.GraphQL.csproj", "{4053591A-1C1A-4A81-8496-F2FF7EAB2D5C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend.Blazor", "Frontend.Blazor", "{0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Blazor.Client", "src\Web\Frontend.Blazor\Frontend.Blazor.Client\Frontend.Blazor.Client.csproj", "{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}"
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frontend.Blazor.Client", "src\Web\Frontend.Blazor\Frontend.Blazor.Client\Frontend.Blazor.Client.csproj", "{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Blazor.Server", "src\Web\Frontend.Blazor\Frontend.Blazor.Server\Frontend.Blazor.Server.csproj", "{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}"
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frontend.Blazor.Server", "src\Web\Frontend.Blazor\Frontend.Blazor.Server\Frontend.Blazor.Server.csproj", "{3BABD4D9-56A1-4BA3-B30C-30E6765AB389}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Blazor.Shared", "src\Web\Frontend.Blazor\Frontend.Blazor.Shared\Frontend.Blazor.Shared.csproj", "{4EB86635-CF79-4D15-909E-C41C98B0B586}"
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frontend.Blazor.Shared", "src\Web\Frontend.Blazor\Frontend.Blazor.Shared\Frontend.Blazor.Shared.csproj", "{4EB86635-CF79-4D15-909E-C41C98B0B586}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CourseRegistration", "CourseRegistration", "{E892AB3D-2291-437A-B6F2-602F59C894DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseRegistration.API", "src\Services\CourseRegistration\CourseRegistration.API\CourseRegistration.API.csproj", "{A5A7393C-AED0-4425-B099-25DA1F75D2BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseRegistration.Domain", "src\Services\CourseRegistration\CourseRegistration.Domain\CourseRegistration.Domain.csproj", "{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseRegistration.Infrastructure", "src\Services\CourseRegistration\CourseRegistration.Infrastructure\CourseRegistration.Infrastructure.csproj", "{624B8B40-F653-4723-A970-D63E86877311}"
ProjectSection(ProjectDependencies) = postProject
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9} = {D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CourseRegistration.FunctionalTests", "src\Services\CourseRegistration\CourseRegistration.FunctionalTests\CourseRegistration.FunctionalTests.csproj", "{FD22CADF-CCFB-40AF-8061-C37E16693D0C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CourseRegistration.UnitTests", "src\Services\CourseRegistration\CourseRegistration.UnitTests\CourseRegistration.UnitTests.csproj", "{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -195,6 +210,66 @@ Global
{4EB86635-CF79-4D15-909E-C41C98B0B586}.Release|x64.Build.0 = Release|Any CPU
{4EB86635-CF79-4D15-909E-C41C98B0B586}.Release|x86.ActiveCfg = Release|Any CPU
{4EB86635-CF79-4D15-909E-C41C98B0B586}.Release|x86.Build.0 = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|x64.ActiveCfg = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|x64.Build.0 = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|x86.ActiveCfg = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Debug|x86.Build.0 = Debug|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|Any CPU.Build.0 = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|x64.ActiveCfg = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|x64.Build.0 = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|x86.ActiveCfg = Release|Any CPU
{A5A7393C-AED0-4425-B099-25DA1F75D2BB}.Release|x86.Build.0 = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|x64.ActiveCfg = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|x64.Build.0 = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Debug|x86.Build.0 = Debug|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|Any CPU.Build.0 = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|x64.ActiveCfg = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|x64.Build.0 = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|x86.ActiveCfg = Release|Any CPU
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9}.Release|x86.Build.0 = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|Any CPU.Build.0 = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|x64.ActiveCfg = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|x64.Build.0 = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|x86.ActiveCfg = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Debug|x86.Build.0 = Debug|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|Any CPU.ActiveCfg = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|Any CPU.Build.0 = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|x64.ActiveCfg = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|x64.Build.0 = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|x86.ActiveCfg = Release|Any CPU
{624B8B40-F653-4723-A970-D63E86877311}.Release|x86.Build.0 = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|x64.ActiveCfg = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|x64.Build.0 = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|x86.ActiveCfg = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Debug|x86.Build.0 = Debug|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|Any CPU.Build.0 = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|x64.ActiveCfg = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|x64.Build.0 = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|x86.ActiveCfg = Release|Any CPU
{FD22CADF-CCFB-40AF-8061-C37E16693D0C}.Release|x86.Build.0 = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|x64.ActiveCfg = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|x64.Build.0 = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|x86.ActiveCfg = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Debug|x86.Build.0 = Debug|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|Any CPU.Build.0 = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|x64.ActiveCfg = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|x64.Build.0 = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|x86.ActiveCfg = Release|Any CPU
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -217,6 +292,12 @@ Global
{53F4E6F9-6B91-45F9-97F9-F6EFA0EBEFCE} = {0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}
{3BABD4D9-56A1-4BA3-B30C-30E6765AB389} = {0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}
{4EB86635-CF79-4D15-909E-C41C98B0B586} = {0C00A596-0FE3-4FA6-B54B-FE2BE83371EF}
{E892AB3D-2291-437A-B6F2-602F59C894DB} = {1C120673-72F4-4679-AC4C-68286E9091A5}
{A5A7393C-AED0-4425-B099-25DA1F75D2BB} = {E892AB3D-2291-437A-B6F2-602F59C894DB}
{D2AA018D-B0EE-4B4B-A050-D90FE76F97F9} = {E892AB3D-2291-437A-B6F2-602F59C894DB}
{624B8B40-F653-4723-A970-D63E86877311} = {E892AB3D-2291-437A-B6F2-602F59C894DB}
{FD22CADF-CCFB-40AF-8061-C37E16693D0C} = {E892AB3D-2291-437A-B6F2-602F59C894DB}
{9E4C30C6-52C0-4DBC-A30A-444A42E5BF7E} = {E892AB3D-2291-437A-B6F2-602F59C894DB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E418719F-3193-403E-AF58-9BE9F94FD8BE}
Expand Down
7 changes: 7 additions & 0 deletions src/ApiGateways/eSchool.GraphQL/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ COPY "src/Services/Enrolling/Enrolling.Infrastructure/Enrolling.Infrastructure.c
COPY "src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj" "src/Services/Enrolling/Enrolling.UnitTests/Enrolling.UnitTests.csproj"
COPY "src/Services/Enrolling/Enrolling.FunctionalTests/Enrolling.FunctionalTests.csproj" "src/Services/Enrolling/Enrolling.FunctionalTests/Enrolling.FunctionalTests.csproj"

COPY "src/Services/CourseRegistration/CourseRegistration.API/CourseRegistration.API.csproj" "src/Services/CourseRegistration/CourseRegistration.API/CourseRegistration.API.csproj"
COPY "src/Services/CourseRegistration/CourseRegistration.Domain/CourseRegistration.Domain.csproj" "src/Services/CourseRegistration/CourseRegistration.Domain/CourseRegistration.Domain.csproj"
COPY "src/Services/CourseRegistration/CourseRegistration.Infrastructure/CourseRegistration.Infrastructure.csproj" "src/Services/CourseRegistration/CourseRegistration.Infrastructure/CourseRegistration.Infrastructure.csproj"
COPY "src/Services/CourseRegistration/CourseRegistration.UnitTests/CourseRegistration.UnitTests.csproj" "src/Services/CourseRegistration/CourseRegistration.UnitTests/Enrolling.UnitTests.csproj"
COPY "src/Services/CourseRegistration/CourseRegistration.FunctionalTests/CourseRegistration.FunctionalTests.csproj" "src/Services/CourseRegistration/CourseRegistration.FunctionalTests/CourseRegistration.FunctionalTests.csproj"

ratanparai marked this conversation as resolved.
Show resolved Hide resolved

COPY "src/Libraries/OpenTelemetry/OpenTelemetry.csproj" "src/Libraries/OpenTelemetry/OpenTelemetry.csproj"

COPY "src/Web/WebStatus/WebStatus.csproj" "src/Web/WebStatus/WebStatus.csproj"
Expand Down
7 changes: 6 additions & 1 deletion src/ApiGateways/eSchool.GraphQL/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace OpenCodeFoundation.ESchool.ApiGateways.ESchool.GraphQL
public class Startup
{
public const string Enrolling = "enrolling";
public const string CourseRegistration = "courseregistration";

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
Expand All @@ -22,9 +23,13 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpClient(Enrolling, c =>
c.BaseAddress = new Uri("http://enrolling.api/graphql"));

services.AddHttpClient(CourseRegistration, c =>
c.BaseAddress = new Uri("http://courseregistration.api/graphql"));

services
.AddGraphQLServer()
.AddRemoteSchema(Enrolling);
.AddRemoteSchema(Enrolling)
.AddRemoteSchema(CourseRegistration);

services.AddOpenTelemetryIntegration();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.Logging;

namespace CourseRegistration.API.Application.Behaviors
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
{
public class LoggingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
{

private readonly ILogger<LoggingBehavior<TRequest, TResponse>> _logger;

public LoggingBehavior(ILogger<LoggingBehavior<TRequest, TResponse>> logger)
{
_logger = logger ?? throw new System.ArgumentNullException(nameof(logger));
}

public async Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next)
{
_logger.LogInformation("Handling request {RequestName} ({@Request})", request.GetType().Name, request);

var response = await next();

_logger.LogInformation(
"Request {RequestName} handled. Response: {@Response}",
request.GetType().Name,
response);

return response;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MediatR;

namespace CourseRegistration.API.Application.Commands
ratanparai marked this conversation as resolved.
Show resolved Hide resolved
{
public class CourseRegistrationCommand : IRequest<bool>
{
public string CourseCode { get; set; }
public string CourseName { get; set; }
public string Description { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CourseRegistration.Infrastructure;
using MediatR;
using Microsoft.Extensions.Logging;

namespace CourseRegistration.API.Application.Commands
{
public class CourseRegistrationCommandHandler : IRequestHandler<CourseRegistrationCommand, bool>
{
private readonly ILogger<CourseRegistrationCommandHandler> _logger;
private readonly CourseRegistrationContext _context;

public CourseRegistrationCommandHandler(CourseRegistrationContext context,
ILogger<CourseRegistrationCommandHandler> logger)
{
_context = context ?? throw new ArgumentException(nameof(context));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task<bool> Handle(CourseRegistrationCommand command, CancellationToken cancellationToken)
{
var courseRegistration = new CourseRegistration.Domain.AggregatesModel.CourseRegistrationAggregate.CourseRegistration(command.CourseCode, command.CourseName, command.Description);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do one of choosing different aggregate root name or changing the service name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your suggestion for the name? We should follow a common convention.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahedee: We have decided use suffix Service for namespace. So the namespace of this class will be CourseRegistrationService.API.Application.Commands. This way we can create the Aggregate with the name CourseRegistration without any issue.

_context.CourseRegistrations.Add(courseRegistration);
await _context.SaveChangesAsync();
return true;

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CourseRegistration.Infrastructure;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace CourseRegistration.API.Application.Queries
{
public class FindAllCourseRegistrationHandler
: IRequestHandler<FindAllCourseRegistrationQuery, IEnumerable<CourseRegistration.Domain.AggregatesModel.CourseRegistrationAggregate.CourseRegistration>>
{
private readonly CourseRegistrationContext _context;


public FindAllCourseRegistrationHandler(CourseRegistrationContext context)
{
_context = context ?? throw new System.ArgumentNullException(nameof(context));
}


public async Task<IEnumerable<Domain.AggregatesModel.CourseRegistrationAggregate.CourseRegistration>> Handle(FindAllCourseRegistrationQuery request, CancellationToken cancellationToken)
{
return await _context.CourseRegistrations.ToListAsync();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediatR;

namespace CourseRegistration.API.Application.Queries
{
public class FindAllCourseRegistrationQuery
:IRequest<IEnumerable<CourseRegistration.Domain.AggregatesModel.CourseRegistrationAggregate.CourseRegistration>>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CourseRegistration.API.Application.Commands;
using CourseRegistration.API.Application.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace CourseRegistration.API.Controllers
{
[ApiController]
[Route("[controller]")]
public class CourseRegistrationController : Controller
{
private readonly IMediator _mediator;

public CourseRegistrationController(IMediator mediator)
{
_mediator = mediator;
}

[HttpGet]
public async Task<IEnumerable<CourseRegistration.Domain.AggregatesModel.CourseRegistrationAggregate.CourseRegistration>> Get()
=> await _mediator.Send(new FindAllCourseRegistrationQuery());

[HttpPost]
public async Task<IActionResult> Post([FromBody] CourseRegistrationCommand command)
{
await _mediator.Send(command);
return Ok();
}
}
}
Loading