diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/CqrsSqlServer.Backend.csproj b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/CqrsSqlServer.Backend.csproj index e533fe8..9b109e5 100644 --- a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/CqrsSqlServer.Backend.csproj +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/CqrsSqlServer.Backend.csproj @@ -16,10 +16,24 @@ + + - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Development.json b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Development.json new file mode 100644 index 0000000..f847e8e --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Development.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + }, + "ConnectionStrings": { + "AkkaSqlConnection": "Server=localhost,1533; Database=Akka; User Id=sa; Password=yourStrong(!)Password; TrustServerCertificate=true;" + } +} \ No newline at end of file diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Production.json b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Production.json new file mode 100644 index 0000000..b4b1b91 --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.Production.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} \ No newline at end of file diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.json b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.json new file mode 100644 index 0000000..b4b1b91 --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.Backend/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} \ No newline at end of file diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServer.DataModel.csproj b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServer.DataModel.csproj new file mode 100644 index 0000000..408af7d --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServer.DataModel.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServerContext.cs b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServerContext.cs new file mode 100644 index 0000000..ab15150 --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/CqrsSqlServerContext.cs @@ -0,0 +1,41 @@ +using CqrsSqlServer.DataModel.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CqrsSqlServer.DataModel; + +public class CqrsSqlServerContext : DbContext +{ + public DbSet Products { get; set; } + + public const int ProductIdMaxLength = 128; + public const int ProductNameMaxLength = 256; + + public CqrsSqlServerContext(DbContextOptions options) + : base(options) + { + } + + // The following configures EF to create a Sqlite database file in the + // special "local" folder for your platform. + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.EnableDetailedErrors(); + base.OnConfiguring(optionsBuilder); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.Property(c => c.ProductId) + .HasMaxLength(ProductIdMaxLength) + .IsRequired(); + + entity.Property(c => c.ProductName) + .HasMaxLength(ProductNameMaxLength) + .IsRequired(); + + entity.HasKey(c => c.ProductId); + }); + } +} \ No newline at end of file diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/Entities/ProductListing.cs b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/Entities/ProductListing.cs new file mode 100644 index 0000000..3471896 --- /dev/null +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.DataModel/Entities/ProductListing.cs @@ -0,0 +1,26 @@ +// ----------------------------------------------------------------------- +// +// Copyright (C) 2013-2024 .NET Foundation +// +// ----------------------------------------------------------------------- + +namespace CqrsSqlServer.DataModel.Entities; + +public class ProductListing +{ + public string ProductId { get; set; } = null!; + + public string ProductName { get; set; } = null!; + + public decimal Price { get; set; } + + public int RemainingInventory { get; set; } + + public int SoldUnits { get; set; } + + public decimal TotalRevenue { get; set; } + + public DateTime Created { get; set; } + + public DateTime LastModified { get; set; } +} \ No newline at end of file diff --git a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.sln b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.sln index 4981584..b4d1cfe 100644 --- a/src/cqrs/cqrs-sqlserver/CqrsSqlServer.sln +++ b/src/cqrs/cqrs-sqlserver/CqrsSqlServer.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CqrsSqlServer.Shared", "Cqr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CqrsSqlServer.Backend", "CqrsSqlServer.Backend\CqrsSqlServer.Backend.csproj", "{E5872C18-242A-4F52-BBE4-CF4CB272CC4E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CqrsSqlServer.DataModel", "CqrsSqlServer.DataModel\CqrsSqlServer.DataModel.csproj", "{A1B9790C-AC65-46C0-8BC5-2C4013F5245D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,5 +26,9 @@ Global {E5872C18-242A-4F52-BBE4-CF4CB272CC4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5872C18-242A-4F52-BBE4-CF4CB272CC4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5872C18-242A-4F52-BBE4-CF4CB272CC4E}.Release|Any CPU.Build.0 = Release|Any CPU + {A1B9790C-AC65-46C0-8BC5-2C4013F5245D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1B9790C-AC65-46C0-8BC5-2C4013F5245D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1B9790C-AC65-46C0-8BC5-2C4013F5245D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1B9790C-AC65-46C0-8BC5-2C4013F5245D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal