Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Main Workflow

on: [push]
on: [push, workflow_dispatch]

jobs:
build:
Expand All @@ -14,17 +14,28 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Build with dotnet
run: dotnet build --configuration Release

- name: Sleep for 30 seconds
uses: jakejarvis/wait-action@master
with:
time: "45s"

- name: Listing all docker containers
run: docker ps -all

- name: SQL Server logs
run: docker logs codelytv-chsarp_ddd_skeleton-mssql

- name: Init databases
run: docker exec codelytv-chsarp_ddd_skeleton-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Your_password123 -d master -i init.sql

- name: Init mooc database
run: docker exec codelytv-chsarp_ddd_skeleton-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Your_password123 -d master -i mooc.sql

- name: Init backoffice database
run: docker exec codelytv-chsarp_ddd_skeleton-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Your_password123 -d master -i backoffice.sql

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.swp
*.log
*.*~
project.lock.json
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion CsharpDDDSkeleton.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.143
VisualStudioVersion = 18.0.59326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ABF745D7-F9BF-4CEE-8A12-DC03FAB68C9A}"
EndProject
Expand Down
12 changes: 12 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1591</NoWarn> <!-- Remove this to turn on warnings for missing XML Comments -->
</PropertyGroup>
</Project>
27 changes: 27 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<ItemGroup>
<PackageVersion Include="Bogus" Version="35.5.1" />
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
<PackageVersion Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.5" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="NEST" Version="7.17.5" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="RabbitMQ.Client" Version="6.8.1" />
<PackageVersion Include="System.Linq.Dynamic.Core" Version="1.3.14" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions apps/Backoffice/Backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>CodelyTv.Apps.Backoffice.Backend</AssemblyName>
<RootNamespace>CodelyTv.Apps.Backoffice.Backend</RootNamespace>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" />
</ItemGroup>


Expand Down
6 changes: 3 additions & 3 deletions apps/Backoffice/Backend/Criteria/FilterParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace CodelyTv.Apps.Backoffice.Backend.Criteria
public class FiltersParam
{
[FromQuery(Name = "filters")]
public List<Dictionary<string, string>> Filters { get; set; }
public List<Dictionary<string, string>> Filters { get; set; } = new List<Dictionary<string, string>>();

[FromQuery(Name = "order_by")]
public string OrderBy { get; set; }
public string OrderBy { get; set; } = string.Empty;

public string Order { get; set; }
public string Order { get; set; } = string.Empty;

public int? Limit { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class CoursesPostWebModel
{
[Uuid]
[Required]
public string Id { get; set; }
public string Id { get; set; } = string.Empty;

[Required]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[Required]
public string Duration { get; set; }
public string Duration { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,35 @@ public static class SummaryByPropertyValidatorHtml
public static IHtmlContent ValidationSummaryByProperty<TModel>(this IHtmlHelper<TModel> helper,
ModelStateDictionary dictionary, string property, string className)
{
if (helper == null)
{
throw new ArgumentNullException(nameof(helper));
}

if (dictionary == null)
{
throw new ArgumentNullException(nameof(dictionary));
}

if (string.IsNullOrEmpty(property))
{
throw new ArgumentNullException(nameof(property));
}

if (className == null)
{
throw new ArgumentNullException(nameof(className));
}

var builder = new StringBuilder();

if (dictionary[property] != null)
foreach (var modelState in dictionary[property].Errors)
if (dictionary.TryGetValue(property, out var modelStateEntry) && modelStateEntry?.Errors != null)
{
foreach (var modelState in modelStateEntry.Errors)
{
builder.Append(CultureInfo.CurrentCulture, $"<p class='{className}'>{modelState.ErrorMessage}</p>");
}
}

return new HtmlString(builder.ToString());
}
Expand Down
16 changes: 8 additions & 8 deletions apps/Backoffice/Frontend/Frontend.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>CodelyTv.Apps.Backoffice.Frontend</AssemblyName>
<RootNamespace>CodelyTv.Apps.Backoffice.Frontend</RootNamespace>
</PropertyGroup>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.2" />
</ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Backoffice\Backoffice.csproj" />
<ProjectReference Include="..\..\..\src\Mooc\Mooc.csproj" />
<ProjectReference Include="..\..\..\src\Shared\Shared.csproj" />
</ItemGroup>
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions apps/Backoffice/Frontend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"Hostname": "localhost",
"port": "5630"
},
"Elasticsearch":
{
"Elasticsearch": {
"Host": "http://localhost",
"Port": "9200",
"IndexPrefix": "backoffice"
Expand Down
6 changes: 3 additions & 3 deletions apps/Mooc/Backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>CodelyTv.Apps.Mooc.Backend</RootNamespace>
<AssemblyName>CodelyTv.Apps.Mooc.Backend</AssemblyName>
</PropertyGroup>
Expand All @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
</ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"/>
</ItemGroup>
</Project>
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version: '3.0'

services:
mssql:
container_name: codelytv-chsarp_ddd_skeleton-mssql
image: mcr.microsoft.com/mssql/server:2019-latest
image: mcr.microsoft.com/mssql/server:2022-latest
user: root
ports:
- 1433:1433
Expand All @@ -17,10 +15,10 @@ services:
- ./database/backoffice.sql:/backoffice.sql
- ./database/data/data:/var/opt/mssql/data
- ./database/data/log:/var/opt/mssql/log
- ./database/data/secrets:/var/opt/mssql/secrets
- ./database/data/secrets:/var/opt/mssql/secrets
rabbitmq:
container_name: codelytv-chsarp_ddd_skeleton-rabbitmq
image: 'rabbitmq:3.7-management'
image: "rabbitmq:3.7-management"
restart: unless-stopped
ports:
- 5630:5672
Expand All @@ -30,7 +28,7 @@ services:
- RABBITMQ_DEFAULT_PASS=c0d3ly
elasticsearch:
container_name: codelytv-chsarp_ddd_skeleton-elasticsearch
image: 'elasticsearch:7.9.1'
image: "elasticsearch:7.9.1"
restart: unless-stopped
ports:
- 9300:9300
Expand Down
6 changes: 3 additions & 3 deletions src/Backoffice/Backoffice.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>CodelyTv.Backoffice</AssemblyName>
<RootNamespace>CodelyTv.Backoffice</RootNamespace>
</PropertyGroup>
Expand All @@ -11,8 +11,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.2" />
<PackageReference Include="NEST" Version="7.17.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
<PackageReference Include="NEST" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@

namespace CodelyTv.Backoffice.Courses.Application.SearchByCriteria
{
public class
SearchBackofficeCoursesByCriteriaQueryHandler : QueryHandler<SearchBackofficeCoursesByCriteriaQuery,
BackofficeCoursesResponse>
public class SearchBackofficeCoursesByCriteriaQueryHandler : QueryHandler<SearchBackofficeCoursesByCriteriaQuery, BackofficeCoursesResponse>
{
private readonly BackofficeCoursesByCriteriaSearcher _searcher;

public SearchBackofficeCoursesByCriteriaQueryHandler(BackofficeCoursesByCriteriaSearcher searcher)
{
_searcher = searcher;
_searcher = searcher ?? throw new ArgumentNullException(nameof(searcher));
}

public async Task<BackofficeCoursesResponse> Handle(SearchBackofficeCoursesByCriteriaQuery query)
{
var filters = Filters.FromValues(query.Filters);
var order = Order.FromValues(query.OrderBy, query.OrderType);
if (query == null)
{
throw new ArgumentNullException(nameof(query));
}

Filters filters = Filters.FromValues(query.Filters) ?? throw new InvalidOperationException("Filters are missing");
var order = Order.FromValues(query.OrderBy ?? throw new InvalidOperationException("OrderBy is missing"), query.OrderType ?? throw new InvalidOperationException("OrderType is missing"));

return await _searcher.Search(filters, order, query.Limit, query.Offset);
}
Expand Down
36 changes: 23 additions & 13 deletions src/Backoffice/Courses/Domain/BackofficeCourse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,51 @@ public class BackofficeCourse

public BackofficeCourse(string id, string name, string duration)
{
Id = id;
Name = name;
Duration = duration;
Id = id ?? throw new ArgumentNullException(nameof(id));
Name = name ?? throw new ArgumentNullException(nameof(name));
Duration = duration ?? throw new ArgumentNullException(nameof(duration));
}

private BackofficeCourse()
{
Id = string.Empty;
Name = string.Empty;
Duration = string.Empty;
}

public Dictionary<string, object> ToPrimitives()
{
var primitives = new Dictionary<string, object>
return new Dictionary<string, object>
{
{"id", Id},
{"name", Name},
{"duration", Duration}
{ "id", Id },
{ "name", Name },
{ "duration", Duration }
};

return primitives;
}

public static BackofficeCourse FromPrimitives(Dictionary<string, object> body)
{
return new BackofficeCourse(body["id"].ToString(), body["name"].ToString(), body["duration"].ToString());
if (body == null)
{
throw new ArgumentNullException(nameof(body));
}

return new BackofficeCourse(
body["id"]?.ToString() ?? throw new InvalidOperationException("ID is missing"),
body["name"]?.ToString() ?? throw new InvalidOperationException("Name is missing"),
body["duration"]?.ToString() ?? throw new InvalidOperationException("Duration is missing")
);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (this == obj) return true;
if (obj == null || GetType() != obj.GetType()) return false;

var item = obj as BackofficeCourse;
if (item == null) return false;

return Id.Equals(item.Id) && Name.Equals(item.Name) &&
Duration.Equals(item.Duration);
return Id.Equals(item.Id) && Name.Equals(item.Name) && Duration.Equals(item.Duration);
}

public override int GetHashCode()
Expand Down
Loading