diff --git a/src/Nox.EntityFramework.Postgres/Nox.EntityFramework.Postgres.csproj b/src/Nox.EntityFramework.Postgres/Nox.EntityFramework.Postgres.csproj index d9fa899d2a..0ccad81eb7 100644 --- a/src/Nox.EntityFramework.Postgres/Nox.EntityFramework.Postgres.csproj +++ b/src/Nox.EntityFramework.Postgres/Nox.EntityFramework.Postgres.csproj @@ -6,6 +6,32 @@ enable + + Nox.EntityFramework.SqlServer + Andre Sharpe,Jan Schutte + Nox entity framework Postgres library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Solution.git + git + nox.png + + + + True + + + + True + + + + + + diff --git a/src/Nox.EntityFramework.Postgres/PostgresDatabaseProvider.cs b/src/Nox.EntityFramework.Postgres/PostgresDatabaseProvider.cs index ed557e9cdf..a78bdde23c 100644 --- a/src/Nox.EntityFramework.Postgres/PostgresDatabaseProvider.cs +++ b/src/Nox.EntityFramework.Postgres/PostgresDatabaseProvider.cs @@ -2,7 +2,7 @@ using Nox.Solution; using Nox.Types; using Nox.Types.EntityFramework.Abstractions; -using Nox.Types.EntityFramework.Configurators; +using Nox.Types.EntityFramework.Types; using Npgsql; namespace Nox.EntityFramework.Postgres; diff --git a/src/Nox.EntityFramework.Postgres/PostgresTextDatabaseConfiguration.cs b/src/Nox.EntityFramework.Postgres/PostgresTextDatabaseConfiguration.cs index 460e4ea193..58b3c414b5 100644 --- a/src/Nox.EntityFramework.Postgres/PostgresTextDatabaseConfiguration.cs +++ b/src/Nox.EntityFramework.Postgres/PostgresTextDatabaseConfiguration.cs @@ -1,5 +1,5 @@ using Nox.Types; -using Nox.Types.EntityFramework.Configurators; +using Nox.Types.EntityFramework.Types; namespace Nox.EntityFramework.Postgres; diff --git a/src/Nox.EntityFramework.SqlServer/Nox.EntityFramework.SqlServer.csproj b/src/Nox.EntityFramework.SqlServer/Nox.EntityFramework.SqlServer.csproj index 9ee968485f..c988b3ea2f 100644 --- a/src/Nox.EntityFramework.SqlServer/Nox.EntityFramework.SqlServer.csproj +++ b/src/Nox.EntityFramework.SqlServer/Nox.EntityFramework.SqlServer.csproj @@ -6,6 +6,24 @@ enable + + Nox.EntityFramework.SqlServer + Andre Sharpe,Jan Schutte + Nox entity framework library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Solution.git + git + nox.png + + + + + + @@ -14,4 +32,12 @@ + + True + + + + True + + diff --git a/src/Nox.EntityFramework.SqlServer/SqlServerDatabaseProvider.cs b/src/Nox.EntityFramework.SqlServer/SqlServerDatabaseProvider.cs index f270c4b1c4..1b2e8cf56d 100644 --- a/src/Nox.EntityFramework.SqlServer/SqlServerDatabaseProvider.cs +++ b/src/Nox.EntityFramework.SqlServer/SqlServerDatabaseProvider.cs @@ -3,7 +3,7 @@ using Nox.Solution; using Nox.Types; using Nox.Types.EntityFramework.Abstractions; -using Nox.Types.EntityFramework.Configurators; +using Nox.Types.EntityFramework.Types; namespace Nox.EntityFramework.SqlServer; diff --git a/src/Nox.EntityFramework.SqlServer/SqlServerTextDatabaseConfigurator.cs b/src/Nox.EntityFramework.SqlServer/SqlServerTextDatabaseConfigurator.cs index 106cda2429..05a8cca23a 100644 --- a/src/Nox.EntityFramework.SqlServer/SqlServerTextDatabaseConfigurator.cs +++ b/src/Nox.EntityFramework.SqlServer/SqlServerTextDatabaseConfigurator.cs @@ -1,5 +1,5 @@ using Nox.Types; -using Nox.Types.EntityFramework.Configurators; +using Nox.Types.EntityFramework.Types; namespace Nox.EntityFramework.SqlServer; diff --git a/src/Nox.EntityFramework.Sqlite/Nox.EntityFramework.Sqlite.csproj b/src/Nox.EntityFramework.Sqlite/Nox.EntityFramework.Sqlite.csproj index 67bc262c1c..da71b91cf7 100644 --- a/src/Nox.EntityFramework.Sqlite/Nox.EntityFramework.Sqlite.csproj +++ b/src/Nox.EntityFramework.Sqlite/Nox.EntityFramework.Sqlite.csproj @@ -6,6 +6,32 @@ enable + + Nox.EntityFramework.SqlServer + Andre Sharpe,Jan Schutte + Nox entity framework SqlServer library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Solution.git + git + nox.png + + + + + + + + True + + + + True + + diff --git a/src/Nox.EntityFramework.Sqlite/SqliteDatabaseProvider.cs b/src/Nox.EntityFramework.Sqlite/SqliteDatabaseProvider.cs index 542d77ae53..56c88eca45 100644 --- a/src/Nox.EntityFramework.Sqlite/SqliteDatabaseProvider.cs +++ b/src/Nox.EntityFramework.Sqlite/SqliteDatabaseProvider.cs @@ -2,7 +2,7 @@ using Nox.Solution; using Nox.Types; using Nox.Types.EntityFramework.Abstractions; -using Nox.Types.EntityFramework.Configurators; +using Nox.Types.EntityFramework.Types; namespace Nox.EntityFramework.Sqlite; diff --git a/src/Nox.Generator.sln b/src/Nox.Generator.sln index 83335edc64..de4333ddb0 100644 --- a/src/Nox.Generator.sln +++ b/src/Nox.Generator.sln @@ -41,19 +41,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Solution", "Nox.Solutio EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Solution.Tests", "..\tests\Nox.Solution.Tests\Nox.Solution.Tests.csproj", "{FAF13809-A3BA-417D-AC25-B682011AB655}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.Types", "Nox.Types\Nox.Types.csproj", "{A19EC5EA-3E4F-47CD-A9B8-802663E9F489}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Types", "Nox.Types\Nox.Types.csproj", "{A19EC5EA-3E4F-47CD-A9B8-802663E9F489}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.Types.EntityFramework", "Nox.Types.EntityFramework\Nox.Types.EntityFramework.csproj", "{3649B470-E632-41F7-A7B9-5331B21B3560}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Types.EntityFramework", "Nox.Types.EntityFramework\Nox.Types.EntityFramework.csproj", "{3649B470-E632-41F7-A7B9-5331B21B3560}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.Types.Tests", "..\tests\Nox.Types.Tests\Nox.Types.Tests.csproj", "{A1C3BA6A-7055-4AFD-9EB3-3B9019D3E7A4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Types.Tests", "..\tests\Nox.Types.Tests\Nox.Types.Tests.csproj", "{A1C3BA6A-7055-4AFD-9EB3-3B9019D3E7A4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DatabaseProviders", "DatabaseProviders", "{873BFCC4-435D-44D7-8287-1FB1574B2319}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.EntityFramework.Postgres", "Nox.EntityFramework.Postgres\Nox.EntityFramework.Postgres.csproj", "{55D717E8-6043-487C-83A9-8AE2E92086D7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.EntityFramework.Postgres", "Nox.EntityFramework.Postgres\Nox.EntityFramework.Postgres.csproj", "{55D717E8-6043-487C-83A9-8AE2E92086D7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.EntityFramework.SqlServer", "Nox.EntityFramework.SqlServer\Nox.EntityFramework.SqlServer.csproj", "{A851D896-AC63-4DC0-98FC-9E1EEA5DACE5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.EntityFramework.SqlServer", "Nox.EntityFramework.SqlServer\Nox.EntityFramework.SqlServer.csproj", "{A851D896-AC63-4DC0-98FC-9E1EEA5DACE5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.EntityFramework.Sqlite", "Nox.EntityFramework.Sqlite\Nox.EntityFramework.Sqlite.csproj", "{049C94B7-EC09-4511-B6BC-21DE2C9C54E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.EntityFramework.Sqlite", "Nox.EntityFramework.Sqlite\Nox.EntityFramework.Sqlite.csproj", "{049C94B7-EC09-4511-B6BC-21DE2C9C54E1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -144,12 +144,12 @@ Global {E054D012-2AA7-4B70-9CDC-253FF510B0C8} = {672E561C-44EA-43EE-8C9D-9E70D8DFB80F} {DBA5FE1B-100F-460F-B192-320B5C85949C} = {672E561C-44EA-43EE-8C9D-9E70D8DFB80F} {7BD651E7-3B5C-4118-963C-629C34F30258} = {FCAB2F70-846A-4C13-8332-48B70C792256} + {9FFE063D-3093-4C0A-AFAA-85D34E5E4AE1} = {873BFCC4-435D-44D7-8287-1FB1574B2319} {6E3F2DD4-6AE5-49B2-B5E4-04B21E073B4F} = {4A930AE8-3A32-48A4-BCDB-0F55FA53AE4B} {FAF13809-A3BA-417D-AC25-B682011AB655} = {4A930AE8-3A32-48A4-BCDB-0F55FA53AE4B} {A19EC5EA-3E4F-47CD-A9B8-802663E9F489} = {110C16ED-A11D-4B5A-ABB2-0E0F4692C77A} - {3649B470-E632-41F7-A7B9-5331B21B3560} = {110C16ED-A11D-4B5A-ABB2-0E0F4692C77A} + {3649B470-E632-41F7-A7B9-5331B21B3560} = {873BFCC4-435D-44D7-8287-1FB1574B2319} {A1C3BA6A-7055-4AFD-9EB3-3B9019D3E7A4} = {110C16ED-A11D-4B5A-ABB2-0E0F4692C77A} - {9FFE063D-3093-4C0A-AFAA-85D34E5E4AE1} = {110C16ED-A11D-4B5A-ABB2-0E0F4692C77A} {55D717E8-6043-487C-83A9-8AE2E92086D7} = {873BFCC4-435D-44D7-8287-1FB1574B2319} {A851D896-AC63-4DC0-98FC-9E1EEA5DACE5} = {873BFCC4-435D-44D7-8287-1FB1574B2319} {049C94B7-EC09-4511-B6BC-21DE2C9C54E1} = {873BFCC4-435D-44D7-8287-1FB1574B2319} diff --git a/src/Nox.Generator/Nox.Generator.csproj b/src/Nox.Generator/Nox.Generator.csproj index 086d657e81..fc3ddf9f68 100644 --- a/src/Nox.Generator/Nox.Generator.csproj +++ b/src/Nox.Generator/Nox.Generator.csproj @@ -1,50 +1,73 @@  - - netstandard2.0 - 10.0 - enable - true - true - true - - - - none - false - AnyCPU - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - $(GetTargetPathDependsOn);GetDependencyTargetPaths - - - - - - - - - - - - - + + netstandard2.0 + 10.0 + enable + true + true + true + + + Nox.Generator + Andre Sharpe,Jan Schutte + Nox generators library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Generator.git + git + nox.png + + + + + + + + none + false + AnyCPU + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + $(GetTargetPathDependsOn);GetDependencyTargetPaths + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Nox.Logging.Serilog/Nox.Logging.Serilog.csproj b/src/Nox.Logging.Serilog/Nox.Logging.Serilog.csproj index 9c6904d1b7..1f7d999fab 100644 --- a/src/Nox.Logging.Serilog/Nox.Logging.Serilog.csproj +++ b/src/Nox.Logging.Serilog/Nox.Logging.Serilog.csproj @@ -6,6 +6,24 @@ enable + + Nox.Logging.Serilog + Andre Sharpe,Jan Schutte + Nox loggin serilog library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Solution.git + git + nox.png + + + + + + @@ -20,4 +38,12 @@ + + + True + + + + True + diff --git a/src/Nox.Monitoring.ElasticApm/Nox.Monitoring.ElasticApm.csproj b/src/Nox.Monitoring.ElasticApm/Nox.Monitoring.ElasticApm.csproj index 3250d56dfd..d92a957008 100644 --- a/src/Nox.Monitoring.ElasticApm/Nox.Monitoring.ElasticApm.csproj +++ b/src/Nox.Monitoring.ElasticApm/Nox.Monitoring.ElasticApm.csproj @@ -5,25 +5,37 @@ enable enable - - Nox.Monitoring.ElasticApm - The Nox Factory - Nox Elastic Apm monitoring library - false - Copyright (c) Andre Sharpe 2022 - true - 1.0.0.0 - 1.0.0.0 - 1.0.0 - MIT - https://github.com/NoxOrg/Nox - https://github.com/NoxOrg/Nox.git - git - + + + Nox.Monitoring.ElasticApm + Andre Sharpe,Jan Schutte + Nox Elastic Apm monitoring library + false + Copyright (c) Andre Sharpe 2023 + true + MIT + https://github.com/NoxOrg/Nox + https://github.com/NoxOrg/Nox.Solution.git + git + nox.png + + + + + + + + + True + + + + True + diff --git a/src/Nox.Solution/Nox.Solution.csproj b/src/Nox.Solution/Nox.Solution.csproj index 687641913e..c6a5c0b9e3 100644 --- a/src/Nox.Solution/Nox.Solution.csproj +++ b/src/Nox.Solution/Nox.Solution.csproj @@ -37,6 +37,14 @@ $(DefineConstants);NETSTANDARD --> + + True + + + + True + + diff --git a/src/Nox.Types.EntityFramework/Configurators/NoxDatabaseConfigurator.cs b/src/Nox.Types.EntityFramework/Abstractions/NoxDatabaseConfigurator.cs similarity index 94% rename from src/Nox.Types.EntityFramework/Configurators/NoxDatabaseConfigurator.cs rename to src/Nox.Types.EntityFramework/Abstractions/NoxDatabaseConfigurator.cs index d1be0f1db3..55c78b5d0f 100644 --- a/src/Nox.Types.EntityFramework/Configurators/NoxDatabaseConfigurator.cs +++ b/src/Nox.Types.EntityFramework/Abstractions/NoxDatabaseConfigurator.cs @@ -1,8 +1,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Nox.Solution; -using Nox.Types.EntityFramework.Abstractions; -namespace Nox.Types.EntityFramework.Configurators +namespace Nox.Types.EntityFramework.Abstractions { public abstract class NoxDatabaseConfigurator : INoxDatabaseConfigurator { @@ -12,7 +11,7 @@ protected NoxDatabaseConfigurator(DictionaryAndre Sharpe,Jan Schutte Nox types entity framework support library false - Copyright (c) Andre Sharpe 2022 + Copyright (c) Andre Sharpe 2023 true MIT https://github.com/NoxOrg/Nox - https://github.com/NoxOrg/Nox.Types.git + https://github.com/NoxOrg/Nox.Type.git git nox.png diff --git a/src/Nox.Types.EntityFramework/Configurators/MoneyDatabaseConfigurator.cs b/src/Nox.Types.EntityFramework/Types/Money/MoneyDatabaseConfigurator.cs similarity index 92% rename from src/Nox.Types.EntityFramework/Configurators/MoneyDatabaseConfigurator.cs rename to src/Nox.Types.EntityFramework/Types/Money/MoneyDatabaseConfigurator.cs index 27c0d023c5..08bdd87835 100644 --- a/src/Nox.Types.EntityFramework/Configurators/MoneyDatabaseConfigurator.cs +++ b/src/Nox.Types.EntityFramework/Types/Money/MoneyDatabaseConfigurator.cs @@ -2,7 +2,7 @@ using Nox.Solution; using Nox.Types.EntityFramework.Abstractions; -namespace Nox.Types.EntityFramework.Configurators; +namespace Nox.Types.EntityFramework.Types; public class MoneyDatabaseConfigurator : INoxTypeDatabaseConfigurator { diff --git a/src/Nox.Types.EntityFramework/Configurators/NumberDatabaseConfigurator.cs b/src/Nox.Types.EntityFramework/Types/Number/NumberDatabaseConfigurator.cs similarity index 95% rename from src/Nox.Types.EntityFramework/Configurators/NumberDatabaseConfigurator.cs rename to src/Nox.Types.EntityFramework/Types/Number/NumberDatabaseConfigurator.cs index be6d6730f9..c9bf12aeb2 100644 --- a/src/Nox.Types.EntityFramework/Configurators/NumberDatabaseConfigurator.cs +++ b/src/Nox.Types.EntityFramework/Types/Number/NumberDatabaseConfigurator.cs @@ -1,9 +1,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Nox.Solution; using Nox.Types.EntityFramework.Abstractions; -using Nox.Types.EntityFramework.Types; -namespace Nox.Types.EntityFramework.Configurators; +namespace Nox.Types.EntityFramework.Types; public class NumberDatabaseConfigurator : INoxTypeDatabaseConfigurator { @@ -50,7 +49,7 @@ public Type GetConverter(NumberTypeOptions typeOptions) } //See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types - + //Fall back to decimal return typeof(NumberToDecimalConverter); } diff --git a/src/Nox.Types.EntityFramework/Configurators/TextDatabaseConfigurator.cs b/src/Nox.Types.EntityFramework/Types/Text/TextDatabaseConfigurator.cs similarity index 91% rename from src/Nox.Types.EntityFramework/Configurators/TextDatabaseConfigurator.cs rename to src/Nox.Types.EntityFramework/Types/Text/TextDatabaseConfigurator.cs index a184bc5194..91a4e54d06 100644 --- a/src/Nox.Types.EntityFramework/Configurators/TextDatabaseConfigurator.cs +++ b/src/Nox.Types.EntityFramework/Types/Text/TextDatabaseConfigurator.cs @@ -2,9 +2,8 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Nox.Solution; using Nox.Types.EntityFramework.Abstractions; -using Nox.Types.EntityFramework.Types; -namespace Nox.Types.EntityFramework.Configurators; +namespace Nox.Types.EntityFramework.Types; public class TextDatabaseConfigurator : INoxTypeDatabaseConfigurator { diff --git a/src/Nox.Types/Nox.Types.csproj b/src/Nox.Types/Nox.Types.csproj index bbbdb18057..6a32ec7c51 100644 --- a/src/Nox.Types/Nox.Types.csproj +++ b/src/Nox.Types/Nox.Types.csproj @@ -11,7 +11,7 @@ Andre Sharpe,Jan Schutte Nox types library false - Copyright (c) Andre Sharpe 2022 + Copyright (c) Andre Sharpe 2023 true MIT https://github.com/NoxOrg/Nox diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/AuditableEntityBase.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/AuditableEntityBase.g.cs new file mode 100644 index 0000000000..a5908d5ce9 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/AuditableEntityBase.g.cs @@ -0,0 +1,40 @@ +// Generated + +#nullable enable + +using System; + +namespace SampleWebApp.Domain; + +public partial class AuditableEntityBase +{ + /// + /// The date and time when this entity was first created (in Coordinated Universal Time). + /// + public DateTime CreatedAtUtc {get; set;} + + /// + /// The user that created the entity. + /// + public string? CreatedBy {get; set;} + + /// + /// The date and time when this entity was last updated (in Coordinated Universal Time). + /// + public DateTime? UpdatedAtUtc {get; set;} + + /// + /// The user that last updated the entity. + /// + public string? UpdatedBy {get; set;} + + /// + /// The date and time when this entity was deleted (in Coordinated Universal Time). + /// + public DateTime? DeletedAtUtc {get; set;} + + /// + /// The user that deleted the entity. + /// + public string? DeletedBy {get; set;} +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesApiController.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesApiController.g.cs new file mode 100644 index 0000000000..c35ca25a10 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesApiController.g.cs @@ -0,0 +1,58 @@ +// Generated + +#nullable enable + +using Nox.Types; +using Microsoft.AspNetCore.Mvc; +using SampleWebApp.Application; +using SampleWebApp.Application.DataTransferObjects; + +namespace SampleWebApp.Presentation.Rest; + +/// +/// Controller for Country entity. The list of countries. +/// +[ApiController] +[Route("Countries")] +public partial class CountriesApiController : ControllerBase +{ + + /// + /// Returns a list of countries for a given continent. + /// + protected GetCountriesByContinentQuery GetCountriesByContinent { get; set; } = null!; + + /// + /// Instructs the service to collect updated population statistics. + /// + protected UpdatePopulationStatisticsCommandHandlerBase UpdatePopulationStatistics { get; set; } = null!; + + public CountriesApiController( + GetCountriesByContinentQuery getCountriesByContinent, + UpdatePopulationStatisticsCommandHandlerBase updatePopulationStatistics + ) + { + GetCountriesByContinent = getCountriesByContinent; + UpdatePopulationStatistics = updatePopulationStatistics; + } + + /// + /// Returns a list of countries for a given continent. + /// + [HttpGet("GetCountriesByContinent")] + public async Task GetCountriesByContinentAsync(Text continentName) + { + var result = await GetCountriesByContinent.ExecuteAsync(continentName); + return Results.Ok(result); + } + + /// + /// Instructs the service to collect updated population statistics. + /// + [HttpPost("UpdatePopulationStatistics")] + public async Task UpdatePopulationStatisticsAsync(UpdatePopulationStatistics command) + { + var result = await UpdatePopulationStatistics.ExecuteAsync(command); + return result.IsSuccess ? Results.Ok(result) : Results.BadRequest(result); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesController.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesController.g.cs new file mode 100644 index 0000000000..4235f60732 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountriesController.g.cs @@ -0,0 +1,140 @@ +// Generated + +#nullable enable + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Deltas; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.EntityFrameworkCore; +using SampleWebApp.Domain; +using SampleWebApp.Infrastructure.Persistence; +using Nox.Types; + +namespace SampleWebApp.Presentation.Api.OData; + +public class CountriesController : ODataController +{ + SampleWebAppDbContext _databaseContext; + + public CountriesController(SampleWebAppDbContext databaseContext) + { + _databaseContext = databaseContext; + } + + [EnableQuery] + public ActionResult> Get() + { + return Ok(_databaseContext.Countries); + } + + [EnableQuery] + public ActionResult Get([FromRoute] string key) + { + var parsedKey = Text.From(key); + var item = _databaseContext.Countries.SingleOrDefault(d => d.Id.Equals(parsedKey)); + + if (item == null) + { + return NotFound(); + } + return Ok(item); + } + + public async Task Post(Country country) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _databaseContext.Countries.Add(country); + + await _databaseContext.SaveChangesAsync(); + + return Created(country); + } + + public async Task Put([FromRoute] string key, [FromBody] Country updatedCountry) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + if (parsedKey != updatedCountry.Id) + { + return BadRequest(); + } + _databaseContext.Entry(updatedCountry).State = EntityState.Modified; + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CountryExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(updatedCountry); + } + + public async Task Patch([FromRoute] string key, [FromBody] Delta country) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + var entity = await _databaseContext.Countries.FindAsync(parsedKey); + if (entity == null) + { + return NotFound(); + } + country.Patch(entity); + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CountryExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(entity); + } + + private bool CountryExists(string key) + { + var parsedKey = Text.From(key); + return _databaseContext.Countries.Any(p => p.Id == parsedKey); + } + + public async Task Delete([FromRoute] string key) + { + var parsedKey = Text.From(key); + var country = await _databaseContext.Countries.FindAsync(parsedKey); + if (country == null) + { + return NotFound(); + } + + _databaseContext.Countries.Remove(country); + await _databaseContext.SaveChangesAsync(); + return NoContent(); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Country.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Country.g.cs new file mode 100644 index 0000000000..7fde1e2354 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Country.g.cs @@ -0,0 +1,91 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System; +using System.Collections.Generic; + +namespace SampleWebApp.Domain; + +/// +/// The list of countries. +/// +public partial class Country : AuditableEntityBase +{ + + /// + /// (Optional) + /// + public Text Id { get; set; } = null!; + + /// + /// The country's common name (required). + /// + public Text Name { get; set; } = null!; + + /// + /// The country's official name (required). + /// + public Text FormalName { get; set; } = null!; + + /// + /// The country's official ISO 4217 alpha-3 code (required). + /// + public Text AlphaCode3 { get; set; } = null!; + + /// + /// The country's official ISO 4217 alpha-2 code (required). + /// + public Text AlphaCode2 { get; set; } = null!; + + /// + /// The country's official ISO 4217 alpha-3 code (required). + /// + public Number NumericCode { get; set; } = null!; + + /// + /// The country's phone dialing codes (comma-delimited) (optional). + /// + public Text? DialingCodes { get; set; } = null!; + + /// + /// The capital city of the country (optional). + /// + public Text? Capital { get; set; } = null!; + + /// + /// Noun denoting the natives of the country (optional). + /// + public Text? Demonym { get; set; } = null!; + + /// + /// Country area in square kilometers (required). + /// + public Number AreaInSquareKilometres { get; set; } = null!; + + /// + /// The region the country is in (required). + /// + public Text GeoRegion { get; set; } = null!; + + /// + /// The sub-region the country is in (required). + /// + public Text GeoSubRegion { get; set; } = null!; + + /// + /// The world region the country is in (required). + /// + public Text GeoWorldRegion { get; set; } = null!; + + /// + /// The estimated population of the country (optional). + /// + public Number? Population { get; set; } = null!; + + /// + /// The top level internet domains regitered to the country (comma-delimited) (optional). + /// + public Text? TopLevelDomains { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryDto.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryDto.g.cs new file mode 100644 index 0000000000..fbafdeb1f7 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryDto.g.cs @@ -0,0 +1,23 @@ +// Generated + +#nullable enable + +// Generated by DtoGenerator::GenerateDto + +using Nox.Abstractions; +using Nox.Types; +using System.Collections.Generic; + +namespace SampleWebApp.Application.DataTransferObjects; + +/// +/// Dto for country information. +/// +public partial class CountryDto : IDynamicDto +{ + + /// + /// The identity of the country, the Iso Alpha 2 code. + /// + public Text? Id { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryInfo.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryInfo.g.cs new file mode 100644 index 0000000000..15779a0736 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryInfo.g.cs @@ -0,0 +1,26 @@ +// Generated + +#nullable enable + +// Generated by DtoGenerator::GenerateDto + +using Nox.Abstractions; +using Nox.Types; +using System.Collections.Generic; + +namespace SampleWebApp.Application.DataTransferObjects; + +public partial class CountryInfo : IDynamicDto +{ + + /// + /// The country's Id. + /// + public CountryCode2? CountryId { get; set; } = null!; + + + /// + /// The country name. + /// + public Text? CountryName { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNames.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNames.g.cs new file mode 100644 index 0000000000..79c7b172ac --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNames.g.cs @@ -0,0 +1,21 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System; +using System.Collections.Generic; + +namespace SampleWebApp.Domain; + +/// +/// The name of a country in other languages. +/// +public partial class CountryLocalNames : AuditableEntityBase +{ + + /// + /// (Optional) + /// + public Text Id { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNamesController.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNamesController.g.cs new file mode 100644 index 0000000000..1cd291bdeb --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryLocalNamesController.g.cs @@ -0,0 +1,140 @@ +// Generated + +#nullable enable + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Deltas; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.EntityFrameworkCore; +using SampleWebApp.Domain; +using SampleWebApp.Infrastructure.Persistence; +using Nox.Types; + +namespace SampleWebApp.Presentation.Api.OData; + +public class CountryLocalNamesController : ODataController +{ + SampleWebAppDbContext _databaseContext; + + public CountryLocalNamesController(SampleWebAppDbContext databaseContext) + { + _databaseContext = databaseContext; + } + + [EnableQuery] + public ActionResult> Get() + { + return Ok(_databaseContext.CountryLocalNames); + } + + [EnableQuery] + public ActionResult Get([FromRoute] string key) + { + var parsedKey = Text.From(key); + var item = _databaseContext.CountryLocalNames.SingleOrDefault(d => d.Id.Equals(parsedKey)); + + if (item == null) + { + return NotFound(); + } + return Ok(item); + } + + public async Task Post(CountryLocalNames countrylocalnames) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _databaseContext.CountryLocalNames.Add(countrylocalnames); + + await _databaseContext.SaveChangesAsync(); + + return Created(countrylocalnames); + } + + public async Task Put([FromRoute] string key, [FromBody] CountryLocalNames updatedCountryLocalNames) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + if (parsedKey != updatedCountryLocalNames.Id) + { + return BadRequest(); + } + _databaseContext.Entry(updatedCountryLocalNames).State = EntityState.Modified; + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CountryLocalNamesExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(updatedCountryLocalNames); + } + + public async Task Patch([FromRoute] string key, [FromBody] Delta countrylocalnames) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + var entity = await _databaseContext.CountryLocalNames.FindAsync(parsedKey); + if (entity == null) + { + return NotFound(); + } + countrylocalnames.Patch(entity); + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CountryLocalNamesExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(entity); + } + + private bool CountryLocalNamesExists(string key) + { + var parsedKey = Text.From(key); + return _databaseContext.CountryLocalNames.Any(p => p.Id == parsedKey); + } + + public async Task Delete([FromRoute] string key) + { + var parsedKey = Text.From(key); + var countrylocalnames = await _databaseContext.CountryLocalNames.FindAsync(parsedKey); + if (countrylocalnames == null) + { + return NotFound(); + } + + _databaseContext.CountryLocalNames.Remove(countrylocalnames); + await _databaseContext.SaveChangesAsync(); + return NoContent(); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameChangedAppEvent.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameChangedAppEvent.g.cs new file mode 100644 index 0000000000..30d5eaea89 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameChangedAppEvent.g.cs @@ -0,0 +1,28 @@ +// Generated + +#nullable enable + +// Generated by DtoGenerator::GenerateEvent + +using Nox.Abstractions; +using Nox.Types; +using System.Collections.Generic; + +namespace SampleWebApp.Application.Events; + +/// +/// An application event raised when the name of a country changes. +/// +public partial class CountryNameChangedAppEvent : INoxApplicationEvent +{ + + /// + /// The identifier of the country. The Iso alpha 2 code. + /// + public CountryCode2? CountryId { get; set; } = null!; + + /// + /// The new name of the country. + /// + public Text? CountryName { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameUpdatedEvent.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameUpdatedEvent.g.cs new file mode 100644 index 0000000000..958ab8e47d --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CountryNameUpdatedEvent.g.cs @@ -0,0 +1,27 @@ +// Generated + +#nullable enable + +// Generated by DomainEventGenerator::GenerateEvent + +using Nox.Abstractions; +using Nox.Types; + +namespace SampleWebApp.Domain; + +/// +/// Raised when the name of a country is changes. +/// +public partial class CountryNameUpdatedEvent : INoxDomainEvent +{ + + /// + /// The identifier of the country. The Iso Alpha2 code of the country. + /// + public CountryCode2? CountryId { get; set; } = null!; + + /// + /// The new name of the country. + /// + public Text? NewCountryName { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CurrenciesController.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CurrenciesController.g.cs new file mode 100644 index 0000000000..cb8ce6b2a0 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/CurrenciesController.g.cs @@ -0,0 +1,140 @@ +// Generated + +#nullable enable + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Deltas; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.EntityFrameworkCore; +using SampleWebApp.Domain; +using SampleWebApp.Infrastructure.Persistence; +using Nox.Types; + +namespace SampleWebApp.Presentation.Api.OData; + +public class CurrenciesController : ODataController +{ + SampleWebAppDbContext _databaseContext; + + public CurrenciesController(SampleWebAppDbContext databaseContext) + { + _databaseContext = databaseContext; + } + + [EnableQuery] + public ActionResult> Get() + { + return Ok(_databaseContext.Currencies); + } + + [EnableQuery] + public ActionResult Get([FromRoute] string key) + { + var parsedKey = Text.From(key); + var item = _databaseContext.Currencies.SingleOrDefault(d => d.Id.Equals(parsedKey)); + + if (item == null) + { + return NotFound(); + } + return Ok(item); + } + + public async Task Post(Currency currency) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _databaseContext.Currencies.Add(currency); + + await _databaseContext.SaveChangesAsync(); + + return Created(currency); + } + + public async Task Put([FromRoute] string key, [FromBody] Currency updatedCurrency) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + if (parsedKey != updatedCurrency.Id) + { + return BadRequest(); + } + _databaseContext.Entry(updatedCurrency).State = EntityState.Modified; + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CurrencyExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(updatedCurrency); + } + + public async Task Patch([FromRoute] string key, [FromBody] Delta currency) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + var entity = await _databaseContext.Currencies.FindAsync(parsedKey); + if (entity == null) + { + return NotFound(); + } + currency.Patch(entity); + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CurrencyExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(entity); + } + + private bool CurrencyExists(string key) + { + var parsedKey = Text.From(key); + return _databaseContext.Currencies.Any(p => p.Id == parsedKey); + } + + public async Task Delete([FromRoute] string key) + { + var parsedKey = Text.From(key); + var currency = await _databaseContext.Currencies.FindAsync(parsedKey); + if (currency == null) + { + return NotFound(); + } + + _databaseContext.Currencies.Remove(currency); + await _databaseContext.SaveChangesAsync(); + return NoContent(); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Currency.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Currency.g.cs new file mode 100644 index 0000000000..b8cd178735 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Currency.g.cs @@ -0,0 +1,33 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System; +using System.Collections.Generic; + +namespace SampleWebApp.Domain; + +/// +/// The list of currencies. +/// +public partial class Currency : AuditableEntityBase +{ + + /// + /// The currency's primary key / identifier (optional). + /// + public Text Id { get; set; } = null!; + + /// + /// The currency's name (required). + /// + public Text Name { get; set; } = null!; + + /// + /// Currency is legal tender for ZeroOrMany Countries + /// + public List Countries { get; set; } = null!; + + public List CurrencyIsLegalTenderForCountry => Countries; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/EntityBase.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/EntityBase.g.cs new file mode 100644 index 0000000000..61a67ada7e --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/EntityBase.g.cs @@ -0,0 +1,18 @@ +// Generated + +#nullable enable + +using System; + +namespace SampleWebApp.Domain; + +/// +/// The base class for all domain entities. +/// +public partial class EntityBase +{ + /// + /// The state of the entity as at this date. + /// + public DateTime AsAt {get; set;} +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Generator.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Generator.g.cs new file mode 100644 index 0000000000..ecfc173c80 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Generator.g.cs @@ -0,0 +1,11 @@ +// Generated + +#nullable enable + +// Found files -> +// - currency.entity.nox.yaml +// - elastic.monitoring.nox.yaml +// - sample.solution.nox.yaml +// - store.entity.nox.yaml +// - generator.nox.yaml +// SUCCESS. diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/GetCountriesByContinentQuery.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/GetCountriesByContinentQuery.g.cs new file mode 100644 index 0000000000..75759492bb --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/GetCountriesByContinentQuery.g.cs @@ -0,0 +1,32 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System.Collections.Generic; +using System.Threading.Tasks; +using SampleWebApp.Domain; +using SampleWebApp.Application.DataTransferObjects; +using SampleWebApp.Infrastructure.Persistence; + +namespace SampleWebApp.Application; + +/// +/// Returns a list of countries for a given continent. +/// +public abstract partial class GetCountriesByContinentQuery +{ + + /// + /// Represents the DB context. + /// + protected SampleWebAppDbContext DbContext { get; set; } = null!; + + public GetCountriesByContinentQuery( + SampleWebAppDbContext dbContext + ) + { + DbContext = dbContext; + } + public abstract Task> ExecuteAsync(Text continentName); +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/NoxServiceCollectionExtension.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/NoxServiceCollectionExtension.g.cs new file mode 100644 index 0000000000..cb7bd67070 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/NoxServiceCollectionExtension.g.cs @@ -0,0 +1,25 @@ +// Generated + +#nullable enable + +using Microsoft.EntityFrameworkCore; +using Nox; +using Nox.EntityFramework.SqlServer; +using Nox.Types.EntityFramework.Abstractions; +using SampleWebApp.Infrastructure.Persistence; + +public static class NoxServiceCollectionExtension +{ + public static IServiceCollection AddNox(this IServiceCollection services) + { + services.AddNoxLib(); + services.AddSingleton>(); + services.AddSingleton(); + services.AddSingleton(); + services.AddDbContext(); + var tmpProvider = services.BuildServiceProvider(); + var dbContext = tmpProvider.GetRequiredService(); + dbContext.Database.EnsureCreated(); + return services; + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/ODataConfiguration.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/ODataConfiguration.g.cs new file mode 100644 index 0000000000..edc2647ca2 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/ODataConfiguration.g.cs @@ -0,0 +1,34 @@ +// Generated + +#nullable enable + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.OData; +using Microsoft.OData.ModelBuilder; +using SampleWebApp.Domain; +namespace SampleWebApp.Presentation.Api.OData; + +public partial class ODataConfiguration +{ + public static void Register(IServiceCollection services) + { + ODataModelBuilder builder = new ODataConventionModelBuilder(); + + builder.EntitySet("Countries"); + builder.EntitySet("Currencies"); + builder.EntitySet("Stores"); + builder.EntitySet("CountryLocalNames"); + + services.AddControllers() + .AddOData(options => options + .Select() + .Filter() + .OrderBy() + .Count() + .Expand() + .SkipToken() + .SetMaxTop(100) + .AddRouteComponents("api", builder.GetEdmModel()) + ); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/SampleWebAppDbContext.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/SampleWebAppDbContext.g.cs new file mode 100644 index 0000000000..eddae13614 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/SampleWebAppDbContext.g.cs @@ -0,0 +1,62 @@ +// Generated + +#nullable enable + +using Microsoft.EntityFrameworkCore; +using Nox.Solution; +using Nox.Types.EntityFramework.Abstractions; +using SampleWebApp.Domain; + +namespace SampleWebApp.Infrastructure.Persistence; + +public partial class SampleWebAppDbContext : DbContext +{ + private readonly NoxSolution _noxSolution; + private readonly INoxDatabaseProvider _dbProvider; + + public SampleWebAppDbContext( + DbContextOptions options, + NoxSolution noxSolution, + INoxDatabaseProvider databaseProvider + ) : base(options) + { + _noxSolution = noxSolution; + _dbProvider = databaseProvider; + } + + public DbSet Countries {get; set;} = null!; + + public DbSet Currencies {get; set;} = null!; + + public DbSet Stores {get; set;} = null!; + + public DbSet CountryLocalNames {get; set;} = null!; + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + base.OnConfiguring(optionsBuilder); + if (_noxSolution.Infrastructure is { Persistence.DatabaseServer: not null }) + { + _dbProvider.ConfigureDbContext(optionsBuilder, "SampleWebApp", _noxSolution.Infrastructure!.Persistence.DatabaseServer); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + if (_noxSolution.Domain != null) + { + foreach (var entity in _noxSolution.Domain.Entities) + { + var type = Type.GetType("SampleWebApp.Domain." + entity.Name); + + if (type != null) + { + ((INoxDatabaseConfigurator)_dbProvider).ConfigureEntity(modelBuilder.Entity(type), entity); + } + } + + } + } +} + diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Store.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Store.g.cs new file mode 100644 index 0000000000..fd77ec669a --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Store.g.cs @@ -0,0 +1,31 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System; +using System.Collections.Generic; + +namespace SampleWebApp.Domain; + +/// +/// Stores. +/// +public partial class Store : AuditableEntityBase +{ + + /// + /// Store Primary Key (optional). + /// + public Text Id { get; set; } = null!; + + /// + /// Store Name (required). + /// + public Text Name { get; set; } = null!; + + /// + /// Physical Money in the Physical Store (required). + /// + public Money PhysicalMoney { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/StoresController.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/StoresController.g.cs new file mode 100644 index 0000000000..9bbdf7fc66 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/StoresController.g.cs @@ -0,0 +1,140 @@ +// Generated + +#nullable enable + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Deltas; +using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Routing.Controllers; +using Microsoft.EntityFrameworkCore; +using SampleWebApp.Domain; +using SampleWebApp.Infrastructure.Persistence; +using Nox.Types; + +namespace SampleWebApp.Presentation.Api.OData; + +public class StoresController : ODataController +{ + SampleWebAppDbContext _databaseContext; + + public StoresController(SampleWebAppDbContext databaseContext) + { + _databaseContext = databaseContext; + } + + [EnableQuery] + public ActionResult> Get() + { + return Ok(_databaseContext.Stores); + } + + [EnableQuery] + public ActionResult Get([FromRoute] string key) + { + var parsedKey = Text.From(key); + var item = _databaseContext.Stores.SingleOrDefault(d => d.Id.Equals(parsedKey)); + + if (item == null) + { + return NotFound(); + } + return Ok(item); + } + + public async Task Post(Store store) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _databaseContext.Stores.Add(store); + + await _databaseContext.SaveChangesAsync(); + + return Created(store); + } + + public async Task Put([FromRoute] string key, [FromBody] Store updatedStore) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + if (parsedKey != updatedStore.Id) + { + return BadRequest(); + } + _databaseContext.Entry(updatedStore).State = EntityState.Modified; + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!StoreExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(updatedStore); + } + + public async Task Patch([FromRoute] string key, [FromBody] Delta store) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var parsedKey = Text.From(key); + var entity = await _databaseContext.Stores.FindAsync(parsedKey); + if (entity == null) + { + return NotFound(); + } + store.Patch(entity); + try + { + await _databaseContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!StoreExists(key)) + { + return NotFound(); + } + else + { + throw; + } + } + return Updated(entity); + } + + private bool StoreExists(string key) + { + var parsedKey = Text.From(key); + return _databaseContext.Stores.Any(p => p.Id == parsedKey); + } + + public async Task Delete([FromRoute] string key) + { + var parsedKey = Text.From(key); + var store = await _databaseContext.Stores.FindAsync(parsedKey); + if (store == null) + { + return NotFound(); + } + + _databaseContext.Stores.Remove(store); + await _databaseContext.SaveChangesAsync(); + return NoContent(); + } +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatistics.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatistics.g.cs new file mode 100644 index 0000000000..9b624fb469 --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatistics.g.cs @@ -0,0 +1,20 @@ +// Generated + +#nullable enable + +// Generated by DtoGenerator::GenerateDto + +using Nox.Abstractions; +using Nox.Types; +using System.Collections.Generic; + +namespace SampleWebApp.Application.DataTransferObjects; + + +/// +/// Instructs the service to collect updated population statistics. +/// +public partial class UpdatePopulationStatistics : IDynamicDto +{ + public CountryCode2? CountryCode { get; set; } = null!; +} diff --git a/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatisticsCommandHandlerBase.g.cs b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatisticsCommandHandlerBase.g.cs new file mode 100644 index 0000000000..a3cbbae4ea --- /dev/null +++ b/src/SampleWebApp/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/UpdatePopulationStatisticsCommandHandlerBase.g.cs @@ -0,0 +1,51 @@ +// Generated + +#nullable enable + +using Nox.Types; +using System.Collections.Generic; +using Nox.Abstractions; +using SampleWebApp.Domain; +using SampleWebApp.Application.DataTransferObjects; +using SampleWebApp.Infrastructure.Persistence; + +namespace SampleWebApp.Application; + +/// +/// Instructs the service to collect updated population statistics. +/// +public abstract partial class UpdatePopulationStatisticsCommandHandlerBase +{ + + /// + /// Represents the DB context. + /// + protected SampleWebAppDbContext DbContext { get; set; } = null!; + + /// + /// Represents the Nox messenger. + /// + protected INoxMessenger Messenger { get; set; } = null!; + + public UpdatePopulationStatisticsCommandHandlerBase( + SampleWebAppDbContext dbContext, + INoxMessenger messenger + ) + { + DbContext = dbContext; + Messenger = messenger; + } + + /// + /// Executes UpdatePopulationStatistics. + /// + public abstract Task ExecuteAsync(UpdatePopulationStatistics command); + + /// + /// Sends CountryNameUpdatedEvent. + /// + public async Task SendCountryNameUpdatedEventDomainEventAsync(CountryNameUpdatedEvent domainEvent) + { + await Messenger.SendMessageAsync(new string[] { "Mediator" }, domainEvent); + } +} diff --git a/tests/Nox.Types.EntityFramework.Tests/UnitTest1.cs b/tests/Nox.Types.EntityFramework.Tests/UnitTest1.cs deleted file mode 100644 index af0094420d..0000000000 --- a/tests/Nox.Types.EntityFramework.Tests/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Nox.Types.EntityFramework.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/tests/Nox.Types.Tests/Nox.Types.Tests.csproj b/tests/Nox.Types.Tests/Nox.Types.Tests.csproj index 3b21412697..29af8fb62f 100644 --- a/tests/Nox.Types.Tests/Nox.Types.Tests.csproj +++ b/tests/Nox.Types.Tests/Nox.Types.Tests.csproj @@ -11,16 +11,16 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all