From 2569dbf7ceffa945708c2c94c414375c4e307e8f Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Mon, 24 Jun 2024 17:32:41 -0500 Subject: [PATCH 1/4] chore; moved entities from data to domain project --- .../Legacy.Application/Services/Catalog/CatalogService.cs | 2 +- .../Legacy.Application/Services/Inventory/InventoryService.cs | 2 +- src/Legacy/Legacy.Data/Configurations/AddressConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/BrandConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/CartConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/CategoryConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/CountryConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/CustomerConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/InventoryConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/ItemConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/ListingConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/ListingErrorConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/OrderConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/PaymentConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/PromotionConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/RestrictionConfig.cs | 2 +- src/Legacy/Legacy.Data/Configurations/WarehouseConfig.cs | 2 +- src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs | 2 +- src/Legacy/Legacy.Data/DbContexts/CustomersDbContext.cs | 2 +- src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs | 2 +- src/Legacy/Legacy.Data/DbContexts/ListingDbContext.cs | 2 +- src/Legacy/Legacy.Data/DbContexts/OrderingDbContext.cs | 2 +- src/Legacy/Legacy.Data/Legacy.Data.csproj | 4 ++++ src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs | 2 +- src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Address.cs | 2 +- .../Entities/AuditableEntity.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Brand.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/BulletPoint.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Cart.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Category.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Country.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Customer.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Inventory.cs | 2 +- .../Entities/InventoryHistory.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Item.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Listing.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/ListingError.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Marketplace.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Order.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/OrderItem.cs | 2 +- src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Payment.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Promotion.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Restriction.cs | 2 +- .../{Legacy.Data => Legacy.Domain}/Entities/Warehouse.cs | 2 +- 45 files changed, 48 insertions(+), 44 deletions(-) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Address.cs (90%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/AuditableEntity.cs (78%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Brand.cs (84%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/BulletPoint.cs (94%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Cart.cs (89%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Category.cs (97%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Country.cs (89%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Customer.cs (92%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Inventory.cs (89%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/InventoryHistory.cs (91%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Item.cs (97%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Listing.cs (95%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/ListingError.cs (92%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Marketplace.cs (83%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Order.cs (96%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/OrderItem.cs (85%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Payment.cs (90%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Promotion.cs (94%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Restriction.cs (87%) rename src/Legacy/{Legacy.Data => Legacy.Domain}/Entities/Warehouse.cs (81%) diff --git a/src/Legacy/Legacy.Application/Services/Catalog/CatalogService.cs b/src/Legacy/Legacy.Application/Services/Catalog/CatalogService.cs index f359d66..c37c63d 100644 --- a/src/Legacy/Legacy.Application/Services/Catalog/CatalogService.cs +++ b/src/Legacy/Legacy.Application/Services/Catalog/CatalogService.cs @@ -1,6 +1,6 @@ using Legacy.Application.Events.Events; using Legacy.Data.DbContexts; -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using MediatR; using Microsoft.EntityFrameworkCore; diff --git a/src/Legacy/Legacy.Application/Services/Inventory/InventoryService.cs b/src/Legacy/Legacy.Application/Services/Inventory/InventoryService.cs index 956baf2..20554d4 100644 --- a/src/Legacy/Legacy.Application/Services/Inventory/InventoryService.cs +++ b/src/Legacy/Legacy.Application/Services/Inventory/InventoryService.cs @@ -1,6 +1,6 @@ using Legacy.Application.Events.Inventory; using Legacy.Data.DbContexts; -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using MediatR; using Microsoft.EntityFrameworkCore; diff --git a/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs b/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs index 7cf38d8..4ff85bb 100644 --- a/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/BrandConfig.cs b/src/Legacy/Legacy.Data/Configurations/BrandConfig.cs index b900394..56a7ed6 100644 --- a/src/Legacy/Legacy.Data/Configurations/BrandConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/BrandConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/CartConfig.cs b/src/Legacy/Legacy.Data/Configurations/CartConfig.cs index a8e8e69..84282e0 100644 --- a/src/Legacy/Legacy.Data/Configurations/CartConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/CartConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/CategoryConfig.cs b/src/Legacy/Legacy.Data/Configurations/CategoryConfig.cs index 99a94f1..2db864d 100644 --- a/src/Legacy/Legacy.Data/Configurations/CategoryConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/CategoryConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/CountryConfig.cs b/src/Legacy/Legacy.Data/Configurations/CountryConfig.cs index 6236d8c..eac0552 100644 --- a/src/Legacy/Legacy.Data/Configurations/CountryConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/CountryConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/CustomerConfig.cs b/src/Legacy/Legacy.Data/Configurations/CustomerConfig.cs index fc96eb6..47b2d8c 100644 --- a/src/Legacy/Legacy.Data/Configurations/CustomerConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/CustomerConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/InventoryConfig.cs b/src/Legacy/Legacy.Data/Configurations/InventoryConfig.cs index 72854d0..c68d47f 100644 --- a/src/Legacy/Legacy.Data/Configurations/InventoryConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/InventoryConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/ItemConfig.cs b/src/Legacy/Legacy.Data/Configurations/ItemConfig.cs index d52113f..a7dd7b0 100644 --- a/src/Legacy/Legacy.Data/Configurations/ItemConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/ItemConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/ListingConfig.cs b/src/Legacy/Legacy.Data/Configurations/ListingConfig.cs index 6bbd94a..7314d71 100644 --- a/src/Legacy/Legacy.Data/Configurations/ListingConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/ListingConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/ListingErrorConfig.cs b/src/Legacy/Legacy.Data/Configurations/ListingErrorConfig.cs index 39a0122..3237ee1 100644 --- a/src/Legacy/Legacy.Data/Configurations/ListingErrorConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/ListingErrorConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/OrderConfig.cs b/src/Legacy/Legacy.Data/Configurations/OrderConfig.cs index 643abd9..4722a02 100644 --- a/src/Legacy/Legacy.Data/Configurations/OrderConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/OrderConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/PaymentConfig.cs b/src/Legacy/Legacy.Data/Configurations/PaymentConfig.cs index 8475c49..f8489ef 100644 --- a/src/Legacy/Legacy.Data/Configurations/PaymentConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/PaymentConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/PromotionConfig.cs b/src/Legacy/Legacy.Data/Configurations/PromotionConfig.cs index af56e29..7158399 100644 --- a/src/Legacy/Legacy.Data/Configurations/PromotionConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/PromotionConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/RestrictionConfig.cs b/src/Legacy/Legacy.Data/Configurations/RestrictionConfig.cs index 105fc4c..fb52b16 100644 --- a/src/Legacy/Legacy.Data/Configurations/RestrictionConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/RestrictionConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/Configurations/WarehouseConfig.cs b/src/Legacy/Legacy.Data/Configurations/WarehouseConfig.cs index e0af139..95cff9f 100644 --- a/src/Legacy/Legacy.Data/Configurations/WarehouseConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/WarehouseConfig.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs index 3dcc4a9..71075d0 100644 --- a/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; diff --git a/src/Legacy/Legacy.Data/DbContexts/CustomersDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/CustomersDbContext.cs index 18df2c6..3074b09 100644 --- a/src/Legacy/Legacy.Data/DbContexts/CustomersDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/CustomersDbContext.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; diff --git a/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs index a2b6e5d..d85122b 100644 --- a/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; diff --git a/src/Legacy/Legacy.Data/DbContexts/ListingDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/ListingDbContext.cs index 23cd2b7..fd74d4f 100644 --- a/src/Legacy/Legacy.Data/DbContexts/ListingDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/ListingDbContext.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; diff --git a/src/Legacy/Legacy.Data/DbContexts/OrderingDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/OrderingDbContext.cs index f3f730d..a4dab2c 100644 --- a/src/Legacy/Legacy.Data/DbContexts/OrderingDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/OrderingDbContext.cs @@ -1,4 +1,4 @@ -using Legacy.Data.Entities; +using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; diff --git a/src/Legacy/Legacy.Data/Legacy.Data.csproj b/src/Legacy/Legacy.Data/Legacy.Data.csproj index cad889b..11830c8 100644 --- a/src/Legacy/Legacy.Data/Legacy.Data.csproj +++ b/src/Legacy/Legacy.Data/Legacy.Data.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs b/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs index eb079ba..03342f7 100644 --- a/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs +++ b/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs @@ -1,6 +1,6 @@ using Bogus; using Legacy.Data.DbContexts; -using Legacy.Data.Entities; +using Legacy.Domain.Entities; namespace Legacy.Data.Seeds; diff --git a/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs b/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs index 41539c8..e37f461 100644 --- a/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs +++ b/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs @@ -1,6 +1,6 @@ using Bogus; using Legacy.Data.DbContexts; -using Legacy.Data.Entities; +using Legacy.Domain.Entities; namespace Legacy.Data.Seeds; diff --git a/src/Legacy/Legacy.Data/Entities/Address.cs b/src/Legacy/Legacy.Domain/Entities/Address.cs similarity index 90% rename from src/Legacy/Legacy.Data/Entities/Address.cs rename to src/Legacy/Legacy.Domain/Entities/Address.cs index 3c633ac..ee64f5a 100644 --- a/src/Legacy/Legacy.Data/Entities/Address.cs +++ b/src/Legacy/Legacy.Domain/Entities/Address.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Address : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/AuditableEntity.cs b/src/Legacy/Legacy.Domain/Entities/AuditableEntity.cs similarity index 78% rename from src/Legacy/Legacy.Data/Entities/AuditableEntity.cs rename to src/Legacy/Legacy.Domain/Entities/AuditableEntity.cs index 0211a0e..cbfe256 100644 --- a/src/Legacy/Legacy.Data/Entities/AuditableEntity.cs +++ b/src/Legacy/Legacy.Domain/Entities/AuditableEntity.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Brand.cs b/src/Legacy/Legacy.Domain/Entities/Brand.cs similarity index 84% rename from src/Legacy/Legacy.Data/Entities/Brand.cs rename to src/Legacy/Legacy.Domain/Entities/Brand.cs index f67c0bb..5b78fb7 100644 --- a/src/Legacy/Legacy.Data/Entities/Brand.cs +++ b/src/Legacy/Legacy.Domain/Entities/Brand.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Brand : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/BulletPoint.cs b/src/Legacy/Legacy.Domain/Entities/BulletPoint.cs similarity index 94% rename from src/Legacy/Legacy.Data/Entities/BulletPoint.cs rename to src/Legacy/Legacy.Domain/Entities/BulletPoint.cs index 43ab08d..4ff8f3f 100644 --- a/src/Legacy/Legacy.Data/Entities/BulletPoint.cs +++ b/src/Legacy/Legacy.Domain/Entities/BulletPoint.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class BulletPoint : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Cart.cs b/src/Legacy/Legacy.Domain/Entities/Cart.cs similarity index 89% rename from src/Legacy/Legacy.Data/Entities/Cart.cs rename to src/Legacy/Legacy.Domain/Entities/Cart.cs index 3351c47..4f55bcf 100644 --- a/src/Legacy/Legacy.Data/Entities/Cart.cs +++ b/src/Legacy/Legacy.Domain/Entities/Cart.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Cart : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Category.cs b/src/Legacy/Legacy.Domain/Entities/Category.cs similarity index 97% rename from src/Legacy/Legacy.Data/Entities/Category.cs rename to src/Legacy/Legacy.Domain/Entities/Category.cs index 2d93a7f..1fcdacf 100644 --- a/src/Legacy/Legacy.Data/Entities/Category.cs +++ b/src/Legacy/Legacy.Domain/Entities/Category.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Category : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Country.cs b/src/Legacy/Legacy.Domain/Entities/Country.cs similarity index 89% rename from src/Legacy/Legacy.Data/Entities/Country.cs rename to src/Legacy/Legacy.Domain/Entities/Country.cs index 95b5010..978566d 100644 --- a/src/Legacy/Legacy.Data/Entities/Country.cs +++ b/src/Legacy/Legacy.Domain/Entities/Country.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Country { diff --git a/src/Legacy/Legacy.Data/Entities/Customer.cs b/src/Legacy/Legacy.Domain/Entities/Customer.cs similarity index 92% rename from src/Legacy/Legacy.Data/Entities/Customer.cs rename to src/Legacy/Legacy.Domain/Entities/Customer.cs index 5d0d3d9..eb32ae6 100644 --- a/src/Legacy/Legacy.Data/Entities/Customer.cs +++ b/src/Legacy/Legacy.Domain/Entities/Customer.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Customer : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Inventory.cs b/src/Legacy/Legacy.Domain/Entities/Inventory.cs similarity index 89% rename from src/Legacy/Legacy.Data/Entities/Inventory.cs rename to src/Legacy/Legacy.Domain/Entities/Inventory.cs index a6a5e24..c836384 100644 --- a/src/Legacy/Legacy.Data/Entities/Inventory.cs +++ b/src/Legacy/Legacy.Domain/Entities/Inventory.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Inventory : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/InventoryHistory.cs b/src/Legacy/Legacy.Domain/Entities/InventoryHistory.cs similarity index 91% rename from src/Legacy/Legacy.Data/Entities/InventoryHistory.cs rename to src/Legacy/Legacy.Domain/Entities/InventoryHistory.cs index f8adc16..0c02435 100644 --- a/src/Legacy/Legacy.Data/Entities/InventoryHistory.cs +++ b/src/Legacy/Legacy.Domain/Entities/InventoryHistory.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class InventoryHistory : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Item.cs b/src/Legacy/Legacy.Domain/Entities/Item.cs similarity index 97% rename from src/Legacy/Legacy.Data/Entities/Item.cs rename to src/Legacy/Legacy.Domain/Entities/Item.cs index 14a9226..a39c84e 100644 --- a/src/Legacy/Legacy.Data/Entities/Item.cs +++ b/src/Legacy/Legacy.Domain/Entities/Item.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Item : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Listing.cs b/src/Legacy/Legacy.Domain/Entities/Listing.cs similarity index 95% rename from src/Legacy/Legacy.Data/Entities/Listing.cs rename to src/Legacy/Legacy.Domain/Entities/Listing.cs index 9ddf1ee..65e09f3 100644 --- a/src/Legacy/Legacy.Data/Entities/Listing.cs +++ b/src/Legacy/Legacy.Domain/Entities/Listing.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Listing : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/ListingError.cs b/src/Legacy/Legacy.Domain/Entities/ListingError.cs similarity index 92% rename from src/Legacy/Legacy.Data/Entities/ListingError.cs rename to src/Legacy/Legacy.Domain/Entities/ListingError.cs index 2d079fa..15ba031 100644 --- a/src/Legacy/Legacy.Data/Entities/ListingError.cs +++ b/src/Legacy/Legacy.Domain/Entities/ListingError.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class ListingError { diff --git a/src/Legacy/Legacy.Data/Entities/Marketplace.cs b/src/Legacy/Legacy.Domain/Entities/Marketplace.cs similarity index 83% rename from src/Legacy/Legacy.Data/Entities/Marketplace.cs rename to src/Legacy/Legacy.Domain/Entities/Marketplace.cs index 7072c83..7775552 100644 --- a/src/Legacy/Legacy.Data/Entities/Marketplace.cs +++ b/src/Legacy/Legacy.Domain/Entities/Marketplace.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Marketplace : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Order.cs b/src/Legacy/Legacy.Domain/Entities/Order.cs similarity index 96% rename from src/Legacy/Legacy.Data/Entities/Order.cs rename to src/Legacy/Legacy.Domain/Entities/Order.cs index 7267201..8b147fa 100644 --- a/src/Legacy/Legacy.Data/Entities/Order.cs +++ b/src/Legacy/Legacy.Domain/Entities/Order.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Order : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/OrderItem.cs b/src/Legacy/Legacy.Domain/Entities/OrderItem.cs similarity index 85% rename from src/Legacy/Legacy.Data/Entities/OrderItem.cs rename to src/Legacy/Legacy.Domain/Entities/OrderItem.cs index 14534e0..b9d4330 100644 --- a/src/Legacy/Legacy.Data/Entities/OrderItem.cs +++ b/src/Legacy/Legacy.Domain/Entities/OrderItem.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class OrderItem : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Payment.cs b/src/Legacy/Legacy.Domain/Entities/Payment.cs similarity index 90% rename from src/Legacy/Legacy.Data/Entities/Payment.cs rename to src/Legacy/Legacy.Domain/Entities/Payment.cs index 60b01cd..0c001b1 100644 --- a/src/Legacy/Legacy.Data/Entities/Payment.cs +++ b/src/Legacy/Legacy.Domain/Entities/Payment.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Payment : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Promotion.cs b/src/Legacy/Legacy.Domain/Entities/Promotion.cs similarity index 94% rename from src/Legacy/Legacy.Data/Entities/Promotion.cs rename to src/Legacy/Legacy.Domain/Entities/Promotion.cs index 28c99e6..02a7fa9 100644 --- a/src/Legacy/Legacy.Data/Entities/Promotion.cs +++ b/src/Legacy/Legacy.Domain/Entities/Promotion.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Promotion : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Restriction.cs b/src/Legacy/Legacy.Domain/Entities/Restriction.cs similarity index 87% rename from src/Legacy/Legacy.Data/Entities/Restriction.cs rename to src/Legacy/Legacy.Domain/Entities/Restriction.cs index 88419e5..e21c2d1 100644 --- a/src/Legacy/Legacy.Data/Entities/Restriction.cs +++ b/src/Legacy/Legacy.Domain/Entities/Restriction.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Restriction : AuditableEntity { diff --git a/src/Legacy/Legacy.Data/Entities/Warehouse.cs b/src/Legacy/Legacy.Domain/Entities/Warehouse.cs similarity index 81% rename from src/Legacy/Legacy.Data/Entities/Warehouse.cs rename to src/Legacy/Legacy.Domain/Entities/Warehouse.cs index 86c78f4..9be5b60 100644 --- a/src/Legacy/Legacy.Data/Entities/Warehouse.cs +++ b/src/Legacy/Legacy.Domain/Entities/Warehouse.cs @@ -1,4 +1,4 @@ -namespace Legacy.Data.Entities; +namespace Legacy.Domain.Entities; public class Warehouse : AuditableEntity { From d87646d821ecc5b86f039e7e5f5ee8c246f35712 Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Mon, 24 Jun 2024 17:36:35 -0500 Subject: [PATCH 2/4] feat; api pagination models --- src/Legacy/Legacy.Api/Models/PaginatedItems.cs | 13 +++++++++++++ src/Legacy/Legacy.Api/Models/PaginatedRequest.cs | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 src/Legacy/Legacy.Api/Models/PaginatedItems.cs create mode 100644 src/Legacy/Legacy.Api/Models/PaginatedRequest.cs diff --git a/src/Legacy/Legacy.Api/Models/PaginatedItems.cs b/src/Legacy/Legacy.Api/Models/PaginatedItems.cs new file mode 100644 index 0000000..bd0d9c0 --- /dev/null +++ b/src/Legacy/Legacy.Api/Models/PaginatedItems.cs @@ -0,0 +1,13 @@ +namespace Legacy.Api.Models; + +public class PaginatedItems(int pageIndex, int pageSize, long count, IEnumerable items) + where TEntity : class +{ + public int PageIndex { get; } = pageIndex; + + public int PageSize { get; } = pageSize; + + public long Count { get; } = count; + + public IEnumerable Items { get;} = items; +} diff --git a/src/Legacy/Legacy.Api/Models/PaginatedRequest.cs b/src/Legacy/Legacy.Api/Models/PaginatedRequest.cs new file mode 100644 index 0000000..3b21e21 --- /dev/null +++ b/src/Legacy/Legacy.Api/Models/PaginatedRequest.cs @@ -0,0 +1,3 @@ +namespace Legacy.Api.Models; + +public record PaginatedRequest(int PageSize = 10, int PageIndex = 0); From 740e3974d7e15fc0d831d639103225e97c8ab602 Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Mon, 24 Jun 2024 17:54:19 -0500 Subject: [PATCH 3/4] chore; cleanup around messaging --- EventSourcingEcommerce.sln | 2 +- src/Legacy/Legacy.Api/Legacy.Api.csproj | 4 +--- src/Legacy/Legacy.Api/Program.cs | 1 - src/Legacy/Legacy.Domain/Events/ListingChanged.cs | 5 +++++ src/Legacy/Legacy.Domain/Events/OrderCreated.cs | 5 +++++ .../Events/IntegrationEvent.cs | 2 +- .../Legacy.SharedMessages.csproj} | 0 7 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/Legacy/Legacy.Domain/Events/ListingChanged.cs create mode 100644 src/Legacy/Legacy.Domain/Events/OrderCreated.cs rename src/Legacy/{Legacy.Messages => Legacy.SharedMessages}/Events/IntegrationEvent.cs (88%) rename src/Legacy/{Legacy.Messages/Legacy.Messages.csproj => Legacy.SharedMessages/Legacy.SharedMessages.csproj} (100%) diff --git a/EventSourcingEcommerce.sln b/EventSourcingEcommerce.sln index 1c3bfba..757da9a 100644 --- a/EventSourcingEcommerce.sln +++ b/EventSourcingEcommerce.sln @@ -59,7 +59,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShoppingCart.Api", "src\Ret EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Legacy.Domain", "src\Legacy\Legacy.Domain\Legacy.Domain.csproj", "{80CEA321-B1F7-49F2-B4C0-6A41DC539BD4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Legacy.Messages", "src\Legacy\Legacy.Messages\Legacy.Messages.csproj", "{3D478A6A-7CF9-452C-9D04-80E09C7F255E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Legacy.SharedMessages", "src\Legacy\Legacy.SharedMessages\Legacy.SharedMessages.csproj", "{3D478A6A-7CF9-452C-9D04-80E09C7F255E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Legacy/Legacy.Api/Legacy.Api.csproj b/src/Legacy/Legacy.Api/Legacy.Api.csproj index 597a384..65ed565 100644 --- a/src/Legacy/Legacy.Api/Legacy.Api.csproj +++ b/src/Legacy/Legacy.Api/Legacy.Api.csproj @@ -5,8 +5,6 @@ - - @@ -20,7 +18,7 @@ - + diff --git a/src/Legacy/Legacy.Api/Program.cs b/src/Legacy/Legacy.Api/Program.cs index d770749..3a9c826 100644 --- a/src/Legacy/Legacy.Api/Program.cs +++ b/src/Legacy/Legacy.Api/Program.cs @@ -2,7 +2,6 @@ using Legacy.Application; using Legacy.Data; using Legacy.Data.DbContexts; -using Legacy.Data.Seeds; using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; diff --git a/src/Legacy/Legacy.Domain/Events/ListingChanged.cs b/src/Legacy/Legacy.Domain/Events/ListingChanged.cs new file mode 100644 index 0000000..a05dab2 --- /dev/null +++ b/src/Legacy/Legacy.Domain/Events/ListingChanged.cs @@ -0,0 +1,5 @@ +using Legacy.Domain.Common; + +namespace Legacy.Domain.Events; + +public record ListingChanged(int ItemId, int ListingId) : DomainEvent; diff --git a/src/Legacy/Legacy.Domain/Events/OrderCreated.cs b/src/Legacy/Legacy.Domain/Events/OrderCreated.cs new file mode 100644 index 0000000..0fc4f6d --- /dev/null +++ b/src/Legacy/Legacy.Domain/Events/OrderCreated.cs @@ -0,0 +1,5 @@ +using Legacy.Domain.Common; + +namespace Legacy.Domain.Events; + +public record OrderCreated(int OrderId) : DomainEvent; diff --git a/src/Legacy/Legacy.Messages/Events/IntegrationEvent.cs b/src/Legacy/Legacy.SharedMessages/Events/IntegrationEvent.cs similarity index 88% rename from src/Legacy/Legacy.Messages/Events/IntegrationEvent.cs rename to src/Legacy/Legacy.SharedMessages/Events/IntegrationEvent.cs index c7de530..e1ac6d4 100644 --- a/src/Legacy/Legacy.Messages/Events/IntegrationEvent.cs +++ b/src/Legacy/Legacy.SharedMessages/Events/IntegrationEvent.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Legacy.Messages.Events; +namespace Legacy.SharedMessages.Events; public record IntegrationEvent { diff --git a/src/Legacy/Legacy.Messages/Legacy.Messages.csproj b/src/Legacy/Legacy.SharedMessages/Legacy.SharedMessages.csproj similarity index 100% rename from src/Legacy/Legacy.Messages/Legacy.Messages.csproj rename to src/Legacy/Legacy.SharedMessages/Legacy.SharedMessages.csproj From e1e5eb93b474876cf617a9b8170be4178d7d2065 Mon Sep 17 00:00:00 2001 From: Erik Shafer Date: Mon, 24 Jun 2024 18:39:21 -0500 Subject: [PATCH 4/4] re-introduced seeding for Catalog, Inventory is WIP --- src/Legacy/Legacy.Api/Program.cs | 5 +- .../Configurations/AddressConfig.cs | 16 +++-- .../DbContexts/CatalogDbContext.cs | 13 ++++ .../DbContexts/InventoryDbContext.cs | 10 +++ src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs | 62 ++++++------------- .../Legacy.Data/Seeds/InventorySeeder.cs | 57 +++++++---------- src/Legacy/Legacy.Domain/Entities/Address.cs | 5 +- .../Legacy.Domain/Entities/Inventory.cs | 4 +- src/Legacy/Legacy.Domain/Entities/Item.cs | 4 +- 9 files changed, 89 insertions(+), 87 deletions(-) diff --git a/src/Legacy/Legacy.Api/Program.cs b/src/Legacy/Legacy.Api/Program.cs index 3a9c826..1b12d9e 100644 --- a/src/Legacy/Legacy.Api/Program.cs +++ b/src/Legacy/Legacy.Api/Program.cs @@ -2,6 +2,7 @@ using Legacy.Application; using Legacy.Data; using Legacy.Data.DbContexts; +using Legacy.Data.Seeds; using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; @@ -66,9 +67,9 @@ var catalogDb = scope.ServiceProvider.GetRequiredService(); catalogDb.Database.EnsureDeleted(); catalogDb.Database.EnsureCreated(); -// catalogDb.Seed(); var inventoryDb = scope.ServiceProvider.GetRequiredService(); -// inventoryDb.Seed(); +// inventoryDb.Database.EnsureDeleted(); +inventoryDb.Database.EnsureCreated(); await app.RunAsync(); diff --git a/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs b/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs index 4ff85bb..8afd03e 100644 --- a/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs +++ b/src/Legacy/Legacy.Data/Configurations/AddressConfig.cs @@ -12,15 +12,23 @@ public void Configure(EntityTypeBuilder
builder) builder.Property(e => e.AddressLine1) .IsRequired() - .HasMaxLength(255); + .HasMaxLength(128); builder.Property(e => e.AddressLine2) .IsRequired(false) - .HasMaxLength(255); + .HasMaxLength(128); builder.Property(e => e.City) .IsRequired() - .HasMaxLength(255); + .HasMaxLength(128); + + builder.Property(e => e.StateProvince) + .IsRequired() + .HasMaxLength(128); + + builder.Property(e => e.PostalCode) + .IsRequired() + .HasMaxLength(64); builder.Property(e => e.CountryId); builder.HasOne(e => e.Country) @@ -29,6 +37,6 @@ public void Configure(EntityTypeBuilder
builder) builder.Property(e => e.Phone) .IsRequired(false) - .HasMaxLength(50); + .HasMaxLength(64); } } diff --git a/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs index 71075d0..9b373ad 100644 --- a/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/CatalogDbContext.cs @@ -1,3 +1,4 @@ +using Legacy.Data.Seeds; using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; @@ -43,6 +44,18 @@ public CatalogDbContext() protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(typeof(CatalogDbContext).Assembly); + + modelBuilder.Entity() + .HasData(CatalogSeeder.GenerateBrands()); + + modelBuilder.Entity() + .HasData(CatalogSeeder.GenerateCategories()); + + modelBuilder.Entity() + .HasData(CatalogSeeder.GenerateItems()); + + modelBuilder.Entity() + .HasData(CatalogSeeder.GenerateRestrictions()); } } diff --git a/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs b/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs index d85122b..345e503 100644 --- a/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs +++ b/src/Legacy/Legacy.Data/DbContexts/InventoryDbContext.cs @@ -1,3 +1,4 @@ +using Legacy.Data.Seeds; using Legacy.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; @@ -42,6 +43,15 @@ public InventoryDbContext() protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(typeof(InventoryDbContext).Assembly); + + modelBuilder.Entity() + .HasData(InventorySeeder.GenerateWarehouses()); + + modelBuilder.Entity() + .HasData(InventorySeeder.GenerateInventories()); + + modelBuilder.Entity() + .HasData(InventorySeeder.GenerateInventoryHistories()); } } diff --git a/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs b/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs index 03342f7..d7e9184 100644 --- a/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs +++ b/src/Legacy/Legacy.Data/Seeds/CatalogSeeder.cs @@ -1,5 +1,4 @@ using Bogus; -using Legacy.Data.DbContexts; using Legacy.Domain.Entities; namespace Legacy.Data.Seeds; @@ -11,54 +10,24 @@ public static class CatalogSeeder private const int MaxItems = 1_024; private const int MaxRestrictions = 128; - public static void Seed(this CatalogDbContext dbContext) - { - // brands - if (dbContext.Brands.Any() is false) - { - var brands = GenerateBrands(); - dbContext.AddRange(brands); - dbContext.SaveChanges(); - } - - // categories - if (dbContext.Categories.Any() is false) - { - - var categories = GenerateCategories(); - dbContext.AddRange(categories); - dbContext.SaveChanges(); - } - - // items - if (dbContext.Items.Any() is false) - { - var items = GenerateItems(); - dbContext.AddRange(items); - dbContext.SaveChanges(); - } - - // restrictions - if (dbContext.Restrictions.Any() is false) - { - var restrictions = GenerateRestrictions(); - dbContext.AddRange(restrictions); - dbContext.SaveChanges(); - } - } - - private static IEnumerable GenerateBrands() + public static IEnumerable GenerateBrands() { + var id = 0; var brandFaker = new Faker() + .UseSeed(100) + .RuleFor(p => p.Id, f => ++id) .RuleFor(p => p.Name, f => f.Company.CompanyName(0)) .RuleFor(p => p.PrimaryContactName, f => f.Name.FullName()); var brands = brandFaker.Generate(MaxBrands); return brands; } - private static IEnumerable GenerateCategories() + public static IEnumerable GenerateCategories() { + var id = 0; var categoryFaker = new Faker() + .UseSeed(100) + .RuleFor(p => p.Id, f => ++id) .RuleFor(p => p.Name, f => f.Commerce.Department(1)) .RuleFor(p => p.Code, f => f.Random.AlphaNumeric(8).ToUpper()) .RuleFor(p => p.Description, f => f.Random.Words(4)); @@ -66,9 +35,12 @@ private static IEnumerable GenerateCategories() return categories; } - private static IEnumerable GenerateItems() + public static IEnumerable GenerateItems() { + var id = 0; var itemFaker = new Faker() + .UseSeed(1_000) + .RuleFor(p => p.Id, f => ++id) .RuleFor(p => p.Name, f => f.Commerce.ProductName()) .RuleFor(p => p.Description, f => f.Commerce.ProductDescription()) .RuleFor(p => p.Color, f => f.Commerce.Color()) @@ -85,18 +57,22 @@ private static IEnumerable GenerateItems() .RuleFor(p => p.Discontinued, f => f.Random.Bool(0.10f)) .RuleFor(p => p.IsVariant, f => f.Random.Bool(0.10f)) .RuleFor(p => p.ChildCouldChokeWarning, f => f.Random.Bool(0.02f)) - // .Ignore(p => p.Brand) + .Ignore(p => p.Brand) .RuleFor(p => p.BrandId, f => f.Random.Number(1, MaxBrands)) - // .Ignore(p => p.Category) + .Ignore(p => p.Category) .RuleFor(p => p.CategoryId, f => f.Random.Number(1, MaxBrands)); var items = itemFaker.Generate(MaxItems); return items; } - private static IEnumerable GenerateRestrictions() + public static IEnumerable GenerateRestrictions() { + var id = 0; var restrictionFaker = new Faker() + .UseSeed(1_000) + .RuleFor(p => p.Id, f => ++id) .RuleFor(p => p.ItemId, f => f.Random.Number(1, MaxItems)) + .Ignore(p => p.Item) .RuleFor(p => p.IsRestricted, f => f.Random.Bool(0.35f)) .RuleFor(p => p.Reason, f => f.Lorem.Sentence(1, 2)); var restrictions = restrictionFaker.Generate(MaxRestrictions); diff --git a/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs b/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs index e37f461..06d35c3 100644 --- a/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs +++ b/src/Legacy/Legacy.Data/Seeds/InventorySeeder.cs @@ -8,51 +8,42 @@ public static class InventorySeeder { private const int MaxInventories = 1_024; private const int MaxInventoryHistories = 1_024; + private const int MaxWarehouses = 13; + private const int MaxQuantityOnHand = 24; + private const float ChanceOfOutOfStock = 0.15f; - public static void Seed(this InventoryDbContext dbContext) - { - // inventories - if (dbContext.Inventories.Any() is false) - { - var inventories = GenerateInventories(); - dbContext.AddRange(inventories); - dbContext.SaveChanges(); - } - - // inventory histories - if (dbContext.InventoryHistories.Any() is false) - { - var inventoryHistories = GenerateInventoryHistories(); - dbContext.AddRange(inventoryHistories); - dbContext.SaveChanges(); - } - - // warehouses - if (dbContext.Warehouses.Any() is false) - { - var warehouses = GenerateWarehouses(); - dbContext.AddRange(warehouses); - dbContext.SaveChanges(); - } - } + private const int MaxBrands = 64; + private const int MaxCategories = 512; + private const int MaxItems = 1_024; + private const int MaxRestrictions = 128; - private static IEnumerable GenerateInventories() + public static IEnumerable GenerateInventories() { - var inventoryFaker = new Faker(); - // TODO: inventory faker rules + var id = 0; + var inventoryFaker = new Faker() + .UseSeed(1_000) + .RuleFor(p => p.Id, f => ++id) + .RuleFor(p => p.ItemId, f => f.Random.Number(1, MaxItems)) + .Ignore(p => p.Item) + .RuleFor(p => p.WarehouseId, f => f.Random.Number(1, MaxWarehouses)) + .Ignore(p => p.Warehouse) + .RuleFor(p => p.Quantity, f => f.Random.Number(1, MaxQuantityOnHand).OrDefault(f, ChanceOfOutOfStock)); var inventories = inventoryFaker.Generate(MaxInventories); return inventories; } - private static IEnumerable GenerateInventoryHistories() + public static IEnumerable GenerateInventoryHistories() { - var inventoryHistoriesFaker = new Faker(); - // TODO: inventory history faker rules + // TODO: more comprehensive inventory history faker rules + var id = 0; + var inventoryHistoriesFaker = new Faker() + .UseSeed(1_000) + .RuleFor(p => p.Id, f => ++id); var inventoryHistories = inventoryHistoriesFaker.Generate(MaxInventories); return inventoryHistories; } - private static IEnumerable GenerateWarehouses() + public static IEnumerable GenerateWarehouses() { var date = new DateTime(2019,02,02,00,00,00); diff --git a/src/Legacy/Legacy.Domain/Entities/Address.cs b/src/Legacy/Legacy.Domain/Entities/Address.cs index ee64f5a..efca405 100644 --- a/src/Legacy/Legacy.Domain/Entities/Address.cs +++ b/src/Legacy/Legacy.Domain/Entities/Address.cs @@ -10,8 +10,11 @@ public class Address : AuditableEntity public string City { get; set; } - public string CountryId { get; set; } + public string StateProvince { get; set; } + + public string PostalCode { get; set; } + public string CountryId { get; set; } public Country Country { get; set; } public string Phone { get; set; } diff --git a/src/Legacy/Legacy.Domain/Entities/Inventory.cs b/src/Legacy/Legacy.Domain/Entities/Inventory.cs index c836384..91db25b 100644 --- a/src/Legacy/Legacy.Domain/Entities/Inventory.cs +++ b/src/Legacy/Legacy.Domain/Entities/Inventory.cs @@ -4,8 +4,8 @@ public class Inventory : AuditableEntity { public long Id { get; set; } public int ItemId { get; set; } - // public Item Item { get; set; } + public Item Item { get; set; } public int WarehouseId { get; set; } - // public Warehouse Warehouse { get; set; } + public Warehouse Warehouse { get; set; } public int Quantity { get; set; } } diff --git a/src/Legacy/Legacy.Domain/Entities/Item.cs b/src/Legacy/Legacy.Domain/Entities/Item.cs index a39c84e..ae62e63 100644 --- a/src/Legacy/Legacy.Domain/Entities/Item.cs +++ b/src/Legacy/Legacy.Domain/Entities/Item.cs @@ -8,9 +8,9 @@ public class Item : AuditableEntity public string Name { get; set; } = default!; public int BrandId { get; set; } - // public Brand Brand { get; set; } = default!; + public Brand Brand { get; set; } = default!; public int CategoryId { get; set; } - // public Category Category { get; set; } = default!; + public Category Category { get; set; } = default!; public bool IsVariant { get; set; } public int? IsVariantOf { get; set; } public bool Discontinued { get; set; }