diff --git a/.editorconfig b/.editorconfig index 52a5b14d..d467f1b2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -102,7 +102,7 @@ csharp_preserve_single_line_statements = false csharp_preserve_single_line_blocks = true csharp_using_directive_placement = outside_namespace:silent csharp_prefer_simple_using_statement = true:suggestion -csharp_style_namespace_declarations = block_scoped:silent +csharp_style_namespace_declarations = file_scoped:silent csharp_style_prefer_method_group_conversion = true:silent csharp_style_prefer_top_level_statements = true:silent csharp_style_expression_bodied_lambdas = true:silent diff --git a/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj b/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj index 954ee60e..68cbcb4d 100644 --- a/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj +++ b/samples/VirtoCommerce.OrdersModule2.Web/VirtoCommerce.OrdersModule2.Web.csproj @@ -5,11 +5,11 @@ Library - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj index 74517b8b..960716e3 100644 --- a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj +++ b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/DbContextOptionsBuilderExtensions.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/DbContextOptionsBuilderExtensions.cs deleted file mode 100644 index 2c79eca1..00000000 --- a/src/VirtoCommerce.OrdersModule.Data.MySql/DbContextOptionsBuilderExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace VirtoCommerce.OrdersModule.Data.MySql -{ - public static class DbContextOptionsBuilderExtensions - { - /// - /// Configures the context to use PostgreSql. - /// - public static DbContextOptionsBuilder UseMySqlDatabase(this DbContextOptionsBuilder builder, string connectionString) => - builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db => db - .MigrationsAssembly(typeof(MySqlDbContextFactory).Assembly.GetName().Name)); - } -} diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDataAssemblyMarker.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDataAssemblyMarker.cs new file mode 100644 index 00000000..b61d8d2b --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDataAssemblyMarker.cs @@ -0,0 +1,5 @@ +namespace VirtoCommerce.OrdersModule.Data.MySql; + +public class MySqlDataAssemblyMarker +{ +} diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDbContextFactory.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDbContextFactory.cs index 94b79d23..08605a58 100644 --- a/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDbContextFactory.cs +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/MySqlDbContextFactory.cs @@ -16,7 +16,7 @@ public OrderDbContext CreateDbContext(string[] args) connectionString, ResolveServerVersion(serverVersion, connectionString), db => db - .MigrationsAssembly(typeof(MySqlDbContextFactory).Assembly.GetName().Name)); + .MigrationsAssembly(typeof(MySqlDataAssemblyMarker).Assembly.GetName().Name)); return new OrderDbContext(builder.Options); } diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj b/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj index b4bef8d0..b8597525 100644 --- a/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/VirtoCommerce.OrdersModule.Data.MySql.csproj @@ -5,11 +5,11 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/DbContextOptionsBuilderExtensions.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/DbContextOptionsBuilderExtensions.cs deleted file mode 100644 index b6ae9f78..00000000 --- a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/DbContextOptionsBuilderExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace VirtoCommerce.OrdersModule.Data.PostgreSql -{ - public static class DbContextOptionsBuilderExtensions - { - /// - /// Configures the context to use PostgreSql. - /// - public static DbContextOptionsBuilder UsePostgreSqlDatabase(this DbContextOptionsBuilder builder, string connectionString) => - builder.UseNpgsql(connectionString, db => db - .MigrationsAssembly(typeof(PostgreSqlDbContextFactory).Assembly.GetName().Name)); - } -} diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDataAssemblyMarker.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDataAssemblyMarker.cs new file mode 100644 index 00000000..ce54a1b2 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDataAssemblyMarker.cs @@ -0,0 +1,5 @@ +namespace VirtoCommerce.OrdersModule.Data.PostgreSql; + +public class PostgreSqlDataAssemblyMarker +{ +} diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDbContextFactory.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDbContextFactory.cs index da45d662..3e54c912 100644 --- a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDbContextFactory.cs +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/PostgreSqlDbContextFactory.cs @@ -13,7 +13,7 @@ public OrderDbContext CreateDbContext(string[] args) builder.UseNpgsql( connectionString, - db => db.MigrationsAssembly(typeof(PostgreSqlDbContextFactory).Assembly.GetName().Name)); + db => db.MigrationsAssembly(typeof(PostgreSqlDataAssemblyMarker).Assembly.GetName().Name)); return new OrderDbContext(builder.Options); } diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj index c14cb1eb..a4e39e9a 100644 --- a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/VirtoCommerce.OrdersModule.Data.PostgreSql.csproj @@ -4,11 +4,11 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/DbContextOptionsBuilderExtensions.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/DbContextOptionsBuilderExtensions.cs deleted file mode 100644 index b8f7c62f..00000000 --- a/src/VirtoCommerce.OrdersModule.Data.SqlServer/DbContextOptionsBuilderExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace VirtoCommerce.OrdersModule.Data.SqlServer -{ - public static class DbContextOptionsBuilderExtensions - { - /// - /// Configures the context to use SqlServer. - /// - public static DbContextOptionsBuilder UseSqlServerDatabase(this DbContextOptionsBuilder builder, string connectionString) - { - return builder.UseSqlServer(connectionString, db => db - .MigrationsAssembly(typeof(SqlServerDbContextFactory).Assembly.GetName().Name)); - } - } -} diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDataAssemblyMarker.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDataAssemblyMarker.cs new file mode 100644 index 00000000..69d745f3 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDataAssemblyMarker.cs @@ -0,0 +1,5 @@ +namespace VirtoCommerce.OrdersModule.Data.SqlServer; + +public class SqlServerDataAssemblyMarker +{ +} diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDbContextFactory.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDbContextFactory.cs index af30dc94..ae016fd0 100644 --- a/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDbContextFactory.cs +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/SqlServerDbContextFactory.cs @@ -13,7 +13,7 @@ public OrderDbContext CreateDbContext(string[] args) builder.UseSqlServer( connectionString, - db => db.MigrationsAssembly(typeof(SqlServerDbContextFactory).Assembly.GetName().Name)); + db => db.MigrationsAssembly(typeof(SqlServerDataAssemblyMarker).Assembly.GetName().Name)); return new OrderDbContext(builder.Options); } diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj b/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj index 270b9ada..c72adda0 100644 --- a/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/VirtoCommerce.OrdersModule.Data.SqlServer.csproj @@ -5,11 +5,11 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj b/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj index c58de163..ca00d56b 100644 --- a/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj +++ b/src/VirtoCommerce.OrdersModule.Data/VirtoCommerce.OrdersModule.Data.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs index 14b08cbb..659a7a1e 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs +++ b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs @@ -321,7 +321,7 @@ public async Task> CreateOrderFromCart(string cartId { CustomerOrder retVal; - using (await AsyncLock.GetLockByKey(cartId).GetReleaserAsync()) + using (await AsyncLock.GetLockByKey(cartId).LockAsync()) { var cart = await _cartService.GetByIdAsync(cartId); retVal = await _customerOrderBuilder.PlaceCustomerOrderFromCartAsync(cart); diff --git a/src/VirtoCommerce.OrdersModule.Web/Module.cs b/src/VirtoCommerce.OrdersModule.Web/Module.cs index 4f71f969..a79354f9 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Module.cs +++ b/src/VirtoCommerce.OrdersModule.Web/Module.cs @@ -40,6 +40,9 @@ using VirtoCommerce.Platform.Core.Security; using VirtoCommerce.Platform.Core.Settings; using VirtoCommerce.Platform.Data.Extensions; +using VirtoCommerce.Platform.Data.MySql.Extensions; +using VirtoCommerce.Platform.Data.PostgreSql.Extensions; +using VirtoCommerce.Platform.Data.SqlServer.Extensions; using VirtoCommerce.SearchModule.Core.Model; using VirtoCommerce.SearchModule.Core.Services; using VirtoCommerce.StoreModule.Core.Model; @@ -64,13 +67,13 @@ public void Initialize(IServiceCollection serviceCollection) switch (databaseProvider) { case "MySql": - options.UseMySqlDatabase(connectionString); + options.UseMySqlDatabase(connectionString, typeof(MySqlDataAssemblyMarker), Configuration); break; case "PostgreSql": - options.UsePostgreSqlDatabase(connectionString); + options.UsePostgreSqlDatabase(connectionString, typeof(PostgreSqlDataAssemblyMarker), Configuration); break; default: - options.UseSqlServerDatabase(connectionString); + options.UseSqlServerDatabase(connectionString, typeof(SqlServerDataAssemblyMarker), Configuration); break; } }); diff --git a/src/VirtoCommerce.OrdersModule.Web/module.manifest b/src/VirtoCommerce.OrdersModule.Web/module.manifest index e8f2b139..78ae71d3 100644 --- a/src/VirtoCommerce.OrdersModule.Web/module.manifest +++ b/src/VirtoCommerce.OrdersModule.Web/module.manifest @@ -3,7 +3,8 @@ VirtoCommerce.Orders 3.826.0 - 3.825.0 + + 3.851.0 @@ -16,6 +17,7 @@ + Order Management Document based flexible order management system