From ff34326a535598a6a7907e863b28c6e44847e7e5 Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Sat, 9 May 2026 16:58:34 +0200 Subject: [PATCH] Refactored database references --- LiteCharms.Abstractions/Constants.cs | 4 ++-- LiteCharms.Extensions/Postgres.cs | 2 +- .../Handlers/CreateCustomerCommandHandler.cs | 2 +- .../Handlers/UpdateCustomerCommandHandler.cs | 2 +- .../Handlers/GetCustomerQueryHandler.cs | 2 +- .../Handlers/GetCustomersQueryHandler.cs | 2 +- .../Handlers/CreateLeadCommandHandler.cs | 2 +- .../Handlers/UpdateLeadCommandHandler.cs | 2 +- .../Handlers/GetCustomerLeadsQueryHandler.cs | 2 +- .../Queries/Handlers/GetLeadsQueryHandler.cs | 2 +- .../CreateNotificationCommandHandler.cs | 2 +- .../UpdateNotificationCommandHandler.cs | 2 +- .../Handlers/GetNotificationQueryHandler.cs | 2 +- .../Handlers/GetNotificationsQueryHandler.cs | 2 +- .../Handlers/CreateOrderCommandHandler.cs | 2 +- .../UpdateOrderStatusCommandHandler.cs | 2 +- .../Handlers/GetCustomerOrdersQueryHandler.cs | 2 +- .../Handlers/GetOrderRefundQueryHandler.cs | 2 +- .../Queries/Handlers/GetOrdersQueryHandler.cs | 2 +- .../Handlers/GetProductPriceQueryHandler.cs | 2 +- .../Handlers/GetProductPricesQueryHandler.cs | 2 +- .../Handlers/GetProductQueryHandler.cs | 2 +- .../Handlers/GetProductsQueryHandler.cs | 2 +- .../AssignQuoteToOrderCommandHandler.cs | 2 +- ...AssignQuoteToShoppingCartCommandHandler.cs | 2 +- .../UpdateQuoteStatusCommandHandler.cs | 2 +- .../Handlers/GetCustomerQuotesQueryHandler.cs | 2 +- .../Queries/Handlers/GetQuoteQueryHandler.cs | 2 +- .../Queries/Handlers/GetQuotesHandler.cs | 2 +- .../Handlers/RefundCustomerCommandHandler.cs | 2 +- .../UpdateOrderRefundCommandHandler.cs | 2 +- .../GetCustomerRefundsQueryHandler.cs | 2 +- .../Queries/Handlers/GetRefundQueryHandler.cs | 2 +- .../AddItemToShoppingCartCommandHandler.cs | 2 +- .../CreateShoppingCartCommandHandler.cs | 2 +- .../EmptyShoppingCartCommandHandler.cs | 2 +- .../RemoveShoppingCartItemCommandHandler.cs | 2 +- .../UpdateShoppingCartItemCommandHandler.cs | 2 +- .../GetCustomerShoppingCartsQueryHandler.cs | 2 +- .../GetShoppingCartItemsQueryHandler.cs | 2 +- .../Handlers/GetShoppingCartQueryHandler.cs | 2 +- .../Database/LeadGeneratorDbContextFactory.cs | 19 ------------------- .../20260502231708_Init.Designer.cs | 2 +- ...123_DefinedEntityRelationships.Designer.cs | 2 +- ...03003624_RemovedLeadIdFromLead.Designer.cs | 2 +- ...260503012708_AddedStatusToLead.Designer.cs | 2 +- ...tedAttributionHashColumnOnLead.Designer.cs | 2 +- ...20260505120450_GeneralisedLead.Designer.cs | 2 +- ...60505123745_AddedNotifications.Designer.cs | 2 +- ...ProcessedColumnToNotifications.Designer.cs | 2 +- ...oppingCartalteredOrderCustomer.Designer.cs | 2 +- .../LeadGeneratorDbContextModelSnapshot.cs | 2 +- ...GeneratorDbContext.cs => ShopDbContext.cs} | 2 +- .../Database/ShopDbContextFactory.cs | 19 +++++++++++++++++++ .../HealthChecks/PostgresHealthCheck.cs | 2 +- 55 files changed, 73 insertions(+), 73 deletions(-) delete mode 100644 LiteCharms.Infrastructure/Database/LeadGeneratorDbContextFactory.cs rename LiteCharms.Infrastructure/Database/{LeadGeneratorDbContext.cs => ShopDbContext.cs} (85%) create mode 100644 LiteCharms.Infrastructure/Database/ShopDbContextFactory.cs diff --git a/LiteCharms.Abstractions/Constants.cs b/LiteCharms.Abstractions/Constants.cs index 9ad6cf5..80b40a6 100644 --- a/LiteCharms.Abstractions/Constants.cs +++ b/LiteCharms.Abstractions/Constants.cs @@ -4,8 +4,8 @@ public static class Constants { public const int QueueBounds = 100000; - public const string LeadGeneratorSchedulerName = "leadgenerator"; - public const string LeadGeneratorSchedulerInstanceId = "golden-dawn"; + public const string ShopSchedulerName = "shop"; + public const string ShopSchedulerInstanceId = "golden-dawn"; public const string EmailServiceBus = nameof(EmailServiceBus); public const string GeneralServiceBus = nameof(GeneralServiceBus); diff --git a/LiteCharms.Extensions/Postgres.cs b/LiteCharms.Extensions/Postgres.cs index d46bdaa..237c601 100644 --- a/LiteCharms.Extensions/Postgres.cs +++ b/LiteCharms.Extensions/Postgres.cs @@ -6,7 +6,7 @@ public static class Postgres { public static IServiceCollection AddLeadGeneratorDatabase(this IServiceCollection services, IConfiguration configuration) { - services.AddPooledDbContextFactory(options => + services.AddPooledDbContextFactory(options => options.UseNpgsql(configuration.GetConnectionString("PostgresLeadGenerator"))); return services; diff --git a/LiteCharms.Features/Customers/Commands/Handlers/CreateCustomerCommandHandler.cs b/LiteCharms.Features/Customers/Commands/Handlers/CreateCustomerCommandHandler.cs index d49e7c1..82f836b 100644 --- a/LiteCharms.Features/Customers/Commands/Handlers/CreateCustomerCommandHandler.cs +++ b/LiteCharms.Features/Customers/Commands/Handlers/CreateCustomerCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Customers.Commands.Handlers; -public class CreateCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class CreateCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(CreateCustomerCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Customers/Commands/Handlers/UpdateCustomerCommandHandler.cs b/LiteCharms.Features/Customers/Commands/Handlers/UpdateCustomerCommandHandler.cs index e16469a..72b9109 100644 --- a/LiteCharms.Features/Customers/Commands/Handlers/UpdateCustomerCommandHandler.cs +++ b/LiteCharms.Features/Customers/Commands/Handlers/UpdateCustomerCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Customers.Commands.Handlers; -public class UpdateCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateCustomerCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Customers/Queries/Handlers/GetCustomerQueryHandler.cs b/LiteCharms.Features/Customers/Queries/Handlers/GetCustomerQueryHandler.cs index 09f1f9b..0f921db 100644 --- a/LiteCharms.Features/Customers/Queries/Handlers/GetCustomerQueryHandler.cs +++ b/LiteCharms.Features/Customers/Queries/Handlers/GetCustomerQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Customers.Queries.Handlers; -public class GetCustomerQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Customers/Queries/Handlers/GetCustomersQueryHandler.cs b/LiteCharms.Features/Customers/Queries/Handlers/GetCustomersQueryHandler.cs index e3e3d73..960ef3a 100644 --- a/LiteCharms.Features/Customers/Queries/Handlers/GetCustomersQueryHandler.cs +++ b/LiteCharms.Features/Customers/Queries/Handlers/GetCustomersQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Customers.Queries.Handlers; -public class GetCustomersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomersQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Leads/Commands/Handlers/CreateLeadCommandHandler.cs b/LiteCharms.Features/Leads/Commands/Handlers/CreateLeadCommandHandler.cs index bd99665..bc8295b 100644 --- a/LiteCharms.Features/Leads/Commands/Handlers/CreateLeadCommandHandler.cs +++ b/LiteCharms.Features/Leads/Commands/Handlers/CreateLeadCommandHandler.cs @@ -3,7 +3,7 @@ using LiteCharms.Infrastructure.Database; namespace LiteCharms.Features.Leads.Commands.Handlers; -public class CreateLeadCommandHandler(IDbContextFactory contextFactory, ISender mediator) : IRequestHandler> +public class CreateLeadCommandHandler(IDbContextFactory contextFactory, ISender mediator) : IRequestHandler> { public async ValueTask> Handle(CreateLeadCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Leads/Commands/Handlers/UpdateLeadCommandHandler.cs b/LiteCharms.Features/Leads/Commands/Handlers/UpdateLeadCommandHandler.cs index 7187005..afaa15c 100644 --- a/LiteCharms.Features/Leads/Commands/Handlers/UpdateLeadCommandHandler.cs +++ b/LiteCharms.Features/Leads/Commands/Handlers/UpdateLeadCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Leads.Commands.Handlers; -public class UpdateLeadCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateLeadCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateLeadCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Leads/Queries/Handlers/GetCustomerLeadsQueryHandler.cs b/LiteCharms.Features/Leads/Queries/Handlers/GetCustomerLeadsQueryHandler.cs index 630b9c5..ed90212 100644 --- a/LiteCharms.Features/Leads/Queries/Handlers/GetCustomerLeadsQueryHandler.cs +++ b/LiteCharms.Features/Leads/Queries/Handlers/GetCustomerLeadsQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Leads.Queries.Handlers; -public class GetCustomerLeadsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerLeadsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerLeadsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Leads/Queries/Handlers/GetLeadsQueryHandler.cs b/LiteCharms.Features/Leads/Queries/Handlers/GetLeadsQueryHandler.cs index 2496116..0ebaafb 100644 --- a/LiteCharms.Features/Leads/Queries/Handlers/GetLeadsQueryHandler.cs +++ b/LiteCharms.Features/Leads/Queries/Handlers/GetLeadsQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Leads.Queries.Handlers; -public class GetLeadsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetLeadsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetLeadsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Notifications/Commands/Handlers/CreateNotificationCommandHandler.cs b/LiteCharms.Features/Notifications/Commands/Handlers/CreateNotificationCommandHandler.cs index e57569b..1c5e251 100644 --- a/LiteCharms.Features/Notifications/Commands/Handlers/CreateNotificationCommandHandler.cs +++ b/LiteCharms.Features/Notifications/Commands/Handlers/CreateNotificationCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Notifications.Commands.Handlers; -public class CreateNotificationCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class CreateNotificationCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(CreateNotificationCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Notifications/Commands/Handlers/UpdateNotificationCommandHandler.cs b/LiteCharms.Features/Notifications/Commands/Handlers/UpdateNotificationCommandHandler.cs index 2adb588..066638a 100644 --- a/LiteCharms.Features/Notifications/Commands/Handlers/UpdateNotificationCommandHandler.cs +++ b/LiteCharms.Features/Notifications/Commands/Handlers/UpdateNotificationCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Notifications.Commands.Handlers; -public class UpdateNotificationCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateNotificationCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateNotificationCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationQueryHandler.cs b/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationQueryHandler.cs index 133e3bf..106dd88 100644 --- a/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationQueryHandler.cs +++ b/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Notifications.Queries.Handlers; -public class GetNotificationQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetNotificationQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetNotificationQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationsQueryHandler.cs b/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationsQueryHandler.cs index f6ac872..70e448f 100644 --- a/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationsQueryHandler.cs +++ b/LiteCharms.Features/Notifications/Queries/Handlers/GetNotificationsQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Notifications.Queries.Handlers; -public class GetNotificationsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetNotificationsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetNotificationsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Orders/Commands/Handlers/CreateOrderCommandHandler.cs b/LiteCharms.Features/Orders/Commands/Handlers/CreateOrderCommandHandler.cs index 1200afb..f06e53b 100644 --- a/LiteCharms.Features/Orders/Commands/Handlers/CreateOrderCommandHandler.cs +++ b/LiteCharms.Features/Orders/Commands/Handlers/CreateOrderCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Orders.Commands.Handlers; -public class CreateOrderCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class CreateOrderCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(CreateOrderCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Orders/Commands/Handlers/UpdateOrderStatusCommandHandler.cs b/LiteCharms.Features/Orders/Commands/Handlers/UpdateOrderStatusCommandHandler.cs index 2524b79..0cfe348 100644 --- a/LiteCharms.Features/Orders/Commands/Handlers/UpdateOrderStatusCommandHandler.cs +++ b/LiteCharms.Features/Orders/Commands/Handlers/UpdateOrderStatusCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Orders.Commands.Handlers; -public class UpdateOrderStatusCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateOrderStatusCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateOrderStatusCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Orders/Queries/Handlers/GetCustomerOrdersQueryHandler.cs b/LiteCharms.Features/Orders/Queries/Handlers/GetCustomerOrdersQueryHandler.cs index 6d683ce..eb9e79f 100644 --- a/LiteCharms.Features/Orders/Queries/Handlers/GetCustomerOrdersQueryHandler.cs +++ b/LiteCharms.Features/Orders/Queries/Handlers/GetCustomerOrdersQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Orders.Queries.Handlers; -public class GetCustomerOrdersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerOrdersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerOrdersQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Orders/Queries/Handlers/GetOrderRefundQueryHandler.cs b/LiteCharms.Features/Orders/Queries/Handlers/GetOrderRefundQueryHandler.cs index 26bc1f2..47dd481 100644 --- a/LiteCharms.Features/Orders/Queries/Handlers/GetOrderRefundQueryHandler.cs +++ b/LiteCharms.Features/Orders/Queries/Handlers/GetOrderRefundQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Orders.Queries.Handlers; -public class GetOrderRefundQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetOrderRefundQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetOrderRefundQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Orders/Queries/Handlers/GetOrdersQueryHandler.cs b/LiteCharms.Features/Orders/Queries/Handlers/GetOrdersQueryHandler.cs index 29b25a3..8276bb4 100644 --- a/LiteCharms.Features/Orders/Queries/Handlers/GetOrdersQueryHandler.cs +++ b/LiteCharms.Features/Orders/Queries/Handlers/GetOrdersQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Orders.Queries.Handlers; -public class GetOrdersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetOrdersQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetOrdersQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Products/Queries/Handlers/GetProductPriceQueryHandler.cs b/LiteCharms.Features/Products/Queries/Handlers/GetProductPriceQueryHandler.cs index 12bcc9f..f73bced 100644 --- a/LiteCharms.Features/Products/Queries/Handlers/GetProductPriceQueryHandler.cs +++ b/LiteCharms.Features/Products/Queries/Handlers/GetProductPriceQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Products.Queries.Handlers; -public class GetProductPriceQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetProductPriceQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetProductPriceQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Products/Queries/Handlers/GetProductPricesQueryHandler.cs b/LiteCharms.Features/Products/Queries/Handlers/GetProductPricesQueryHandler.cs index 0f1f5af..c9eac0a 100644 --- a/LiteCharms.Features/Products/Queries/Handlers/GetProductPricesQueryHandler.cs +++ b/LiteCharms.Features/Products/Queries/Handlers/GetProductPricesQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Products.Queries.Handlers; -public class GetProductPricesQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetProductPricesQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetProductPricesQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Products/Queries/Handlers/GetProductQueryHandler.cs b/LiteCharms.Features/Products/Queries/Handlers/GetProductQueryHandler.cs index cca604f..6cf09c6 100644 --- a/LiteCharms.Features/Products/Queries/Handlers/GetProductQueryHandler.cs +++ b/LiteCharms.Features/Products/Queries/Handlers/GetProductQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Products.Queries.Handlers; -public class GetProductQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetProductQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetProductQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Products/Queries/Handlers/GetProductsQueryHandler.cs b/LiteCharms.Features/Products/Queries/Handlers/GetProductsQueryHandler.cs index 1b99b16..3fc0366 100644 --- a/LiteCharms.Features/Products/Queries/Handlers/GetProductsQueryHandler.cs +++ b/LiteCharms.Features/Products/Queries/Handlers/GetProductsQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Products.Queries.Handlers; -public class GetProductsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetProductsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetProductsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToOrderCommandHandler.cs b/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToOrderCommandHandler.cs index 4178e6b..3145cd4 100644 --- a/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToOrderCommandHandler.cs +++ b/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToOrderCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Quotes.Commands.Handlers; -public class AssignQuoteToOrderCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class AssignQuoteToOrderCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(AssignQuoteToOrderCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToShoppingCartCommandHandler.cs b/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToShoppingCartCommandHandler.cs index 8638079..443c907 100644 --- a/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToShoppingCartCommandHandler.cs +++ b/LiteCharms.Features/Quotes/Commands/Handlers/AssignQuoteToShoppingCartCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Quotes.Commands.Handlers; -public class AssignQuoteToShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class AssignQuoteToShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(AssignQuoteToShoppingCartCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Commands/Handlers/UpdateQuoteStatusCommandHandler.cs b/LiteCharms.Features/Quotes/Commands/Handlers/UpdateQuoteStatusCommandHandler.cs index 70c5191..a279370 100644 --- a/LiteCharms.Features/Quotes/Commands/Handlers/UpdateQuoteStatusCommandHandler.cs +++ b/LiteCharms.Features/Quotes/Commands/Handlers/UpdateQuoteStatusCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Quotes.Commands.Handlers; -public class UpdateQuoteStatusCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateQuoteStatusCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateQuoteStatusCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Queries/Handlers/GetCustomerQuotesQueryHandler.cs b/LiteCharms.Features/Quotes/Queries/Handlers/GetCustomerQuotesQueryHandler.cs index 3243924..11c2169 100644 --- a/LiteCharms.Features/Quotes/Queries/Handlers/GetCustomerQuotesQueryHandler.cs +++ b/LiteCharms.Features/Quotes/Queries/Handlers/GetCustomerQuotesQueryHandler.cs @@ -5,7 +5,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Quotes.Queries.Handlers; -public class GetCustomerQuotesQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerQuotesQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerQuotesQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Queries/Handlers/GetQuoteQueryHandler.cs b/LiteCharms.Features/Quotes/Queries/Handlers/GetQuoteQueryHandler.cs index d8343cd..8986161 100644 --- a/LiteCharms.Features/Quotes/Queries/Handlers/GetQuoteQueryHandler.cs +++ b/LiteCharms.Features/Quotes/Queries/Handlers/GetQuoteQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Quotes.Queries.Handlers; -public class GetQuoteQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetQuoteQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetQuoteQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Quotes/Queries/Handlers/GetQuotesHandler.cs b/LiteCharms.Features/Quotes/Queries/Handlers/GetQuotesHandler.cs index adfae5e..3d548b0 100644 --- a/LiteCharms.Features/Quotes/Queries/Handlers/GetQuotesHandler.cs +++ b/LiteCharms.Features/Quotes/Queries/Handlers/GetQuotesHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Quotes.Queries.Handlers; -public class GetQuotesHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetQuotesHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetQuotesQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Refunds/Commands/Handlers/RefundCustomerCommandHandler.cs b/LiteCharms.Features/Refunds/Commands/Handlers/RefundCustomerCommandHandler.cs index 0b52018..c4021f7 100644 --- a/LiteCharms.Features/Refunds/Commands/Handlers/RefundCustomerCommandHandler.cs +++ b/LiteCharms.Features/Refunds/Commands/Handlers/RefundCustomerCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Refunds.Commands.Handlers; -public class RefundCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class RefundCustomerCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(RefundCustomerCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Refunds/Commands/Handlers/UpdateOrderRefundCommandHandler.cs b/LiteCharms.Features/Refunds/Commands/Handlers/UpdateOrderRefundCommandHandler.cs index de1bf04..9f6fb00 100644 --- a/LiteCharms.Features/Refunds/Commands/Handlers/UpdateOrderRefundCommandHandler.cs +++ b/LiteCharms.Features/Refunds/Commands/Handlers/UpdateOrderRefundCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.Refunds.Commands.Handlers; -public class UpdateOrderRefundCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateOrderRefundCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateOrderRefundCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Refunds/Queries/Handlers/GetCustomerRefundsQueryHandler.cs b/LiteCharms.Features/Refunds/Queries/Handlers/GetCustomerRefundsQueryHandler.cs index 34b9f21..c198b76 100644 --- a/LiteCharms.Features/Refunds/Queries/Handlers/GetCustomerRefundsQueryHandler.cs +++ b/LiteCharms.Features/Refunds/Queries/Handlers/GetCustomerRefundsQueryHandler.cs @@ -5,7 +5,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Refunds.Queries.Handlers; -public class GetCustomerRefundsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerRefundsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerRefundsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/Refunds/Queries/Handlers/GetRefundQueryHandler.cs b/LiteCharms.Features/Refunds/Queries/Handlers/GetRefundQueryHandler.cs index 29bd3e5..2561031 100644 --- a/LiteCharms.Features/Refunds/Queries/Handlers/GetRefundQueryHandler.cs +++ b/LiteCharms.Features/Refunds/Queries/Handlers/GetRefundQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.Refunds.Queries.Handlers; -public class GetRefundQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetRefundQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetRefundQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/AddItemToShoppingCartCommandHandler.cs b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/AddItemToShoppingCartCommandHandler.cs index 3490517..dc4a50d 100644 --- a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/AddItemToShoppingCartCommandHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/AddItemToShoppingCartCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.ShoppingCarts.Commands.Handlers; -public class AddItemToShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class AddItemToShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(AddItemToShoppingCartCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/CreateShoppingCartCommandHandler.cs b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/CreateShoppingCartCommandHandler.cs index c6d17b0..241af60 100644 --- a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/CreateShoppingCartCommandHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/CreateShoppingCartCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.ShoppingCarts.Commands.Handlers; -public class CreateShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class CreateShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(CreateShoppingCartCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/EmptyShoppingCartCommandHandler.cs b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/EmptyShoppingCartCommandHandler.cs index 2787a8c..3f3ce2f 100644 --- a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/EmptyShoppingCartCommandHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/EmptyShoppingCartCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.ShoppingCarts.Commands.Handlers; -public class EmptyShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class EmptyShoppingCartCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(EmptyShoppingCartCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/RemoveShoppingCartItemCommandHandler.cs b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/RemoveShoppingCartItemCommandHandler.cs index 1d7944d..73255c5 100644 --- a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/RemoveShoppingCartItemCommandHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/RemoveShoppingCartItemCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.ShoppingCarts.Commands.Handlers; -public class RemoveShoppingCartItemCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class RemoveShoppingCartItemCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(RemoveShoppingCartItemCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/UpdateShoppingCartItemCommandHandler.cs b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/UpdateShoppingCartItemCommandHandler.cs index b1880ec..42b362f 100644 --- a/LiteCharms.Features/ShoppingCarts/Commands/Handlers/UpdateShoppingCartItemCommandHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Commands/Handlers/UpdateShoppingCartItemCommandHandler.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Features.ShoppingCarts.Commands.Handlers; -public class UpdateShoppingCartItemCommandHandler(IDbContextFactory contextFactory) : IRequestHandler +public class UpdateShoppingCartItemCommandHandler(IDbContextFactory contextFactory) : IRequestHandler { public async ValueTask Handle(UpdateShoppingCartItemCommand request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetCustomerShoppingCartsQueryHandler.cs b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetCustomerShoppingCartsQueryHandler.cs index d4a6885..d6bde0f 100644 --- a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetCustomerShoppingCartsQueryHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetCustomerShoppingCartsQueryHandler.cs @@ -5,7 +5,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.ShoppingCarts.Queries.Handlers; -public class GetCustomerShoppingCartsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetCustomerShoppingCartsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetCustomerShoppingCartsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartItemsQueryHandler.cs b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartItemsQueryHandler.cs index e523c25..0e7104c 100644 --- a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartItemsQueryHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartItemsQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.ShoppingCarts.Queries.Handlers; -public class GetShoppingCartItemsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetShoppingCartItemsQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetShoppingCartItemsQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartQueryHandler.cs b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartQueryHandler.cs index d58ffc3..6793e22 100644 --- a/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartQueryHandler.cs +++ b/LiteCharms.Features/ShoppingCarts/Queries/Handlers/GetShoppingCartQueryHandler.cs @@ -4,7 +4,7 @@ using LiteCharms.Models; namespace LiteCharms.Features.ShoppingCarts.Queries.Handlers; -public class GetShoppingCartQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> +public class GetShoppingCartQueryHandler(IDbContextFactory contextFactory) : IRequestHandler> { public async ValueTask> Handle(GetShoppingCartQuery request, CancellationToken cancellationToken) { diff --git a/LiteCharms.Infrastructure/Database/LeadGeneratorDbContextFactory.cs b/LiteCharms.Infrastructure/Database/LeadGeneratorDbContextFactory.cs deleted file mode 100644 index 0a18c5b..0000000 --- a/LiteCharms.Infrastructure/Database/LeadGeneratorDbContextFactory.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace LiteCharms.Infrastructure.Database; - -public class LeadGeneratorDbContextFactory : IDesignTimeDbContextFactory -{ - public LeadGeneratorDbContext CreateDbContext(string[] args) - { - var configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddUserSecrets(typeof(LeadGeneratorDbContext).Assembly) - .AddJsonFile("appsettings.json") - .AddEnvironmentVariables() - .Build(); - - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseNpgsql(configuration.GetConnectionString("PostgresLeadGenerator")); - - return new LeadGeneratorDbContext(optionsBuilder.Options); - } -} diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260502231708_Init.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260502231708_Init.Designer.cs index 129f9fd..5168e4c 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260502231708_Init.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260502231708_Init.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260502231708_Init")] partial class Init { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260503002123_DefinedEntityRelationships.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260503002123_DefinedEntityRelationships.Designer.cs index 4d9b3f9..03d73e0 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260503002123_DefinedEntityRelationships.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260503002123_DefinedEntityRelationships.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260503002123_DefinedEntityRelationships")] partial class DefinedEntityRelationships { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260503003624_RemovedLeadIdFromLead.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260503003624_RemovedLeadIdFromLead.Designer.cs index 0fac239..f0f5e49 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260503003624_RemovedLeadIdFromLead.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260503003624_RemovedLeadIdFromLead.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260503003624_RemovedLeadIdFromLead")] partial class RemovedLeadIdFromLead { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260503012708_AddedStatusToLead.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260503012708_AddedStatusToLead.Designer.cs index 036f3c2..17dfee8 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260503012708_AddedStatusToLead.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260503012708_AddedStatusToLead.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260503012708_AddedStatusToLead")] partial class AddedStatusToLead { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260503133855_CorrectedAttributionHashColumnOnLead.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260503133855_CorrectedAttributionHashColumnOnLead.Designer.cs index 0a1ad72..6e40369 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260503133855_CorrectedAttributionHashColumnOnLead.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260503133855_CorrectedAttributionHashColumnOnLead.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260503133855_CorrectedAttributionHashColumnOnLead")] partial class CorrectedAttributionHashColumnOnLead { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260505120450_GeneralisedLead.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260505120450_GeneralisedLead.Designer.cs index 6f22981..d9c0beb 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260505120450_GeneralisedLead.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260505120450_GeneralisedLead.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260505120450_GeneralisedLead")] partial class GeneralisedLead { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260505123745_AddedNotifications.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260505123745_AddedNotifications.Designer.cs index afd8292..9f54643 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260505123745_AddedNotifications.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260505123745_AddedNotifications.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260505123745_AddedNotifications")] partial class AddedNotifications { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260505124135_AddedProcessedColumnToNotifications.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260505124135_AddedProcessedColumnToNotifications.Designer.cs index ae0228c..8ec4ca5 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260505124135_AddedProcessedColumnToNotifications.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260505124135_AddedProcessedColumnToNotifications.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260505124135_AddedProcessedColumnToNotifications")] partial class AddedProcessedColumnToNotifications { diff --git a/LiteCharms.Infrastructure/Database/Migrations/20260505202859_AddedQuoteShoppingCartalteredOrderCustomer.Designer.cs b/LiteCharms.Infrastructure/Database/Migrations/20260505202859_AddedQuoteShoppingCartalteredOrderCustomer.Designer.cs index 3707216..90c8e8f 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/20260505202859_AddedQuoteShoppingCartalteredOrderCustomer.Designer.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/20260505202859_AddedQuoteShoppingCartalteredOrderCustomer.Designer.cs @@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Database.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] [Migration("20260505202859_AddedQuoteShoppingCartalteredOrderCustomer")] partial class AddedQuoteShoppingCartalteredOrderCustomer { diff --git a/LiteCharms.Infrastructure/Database/Migrations/LeadGeneratorDbContextModelSnapshot.cs b/LiteCharms.Infrastructure/Database/Migrations/LeadGeneratorDbContextModelSnapshot.cs index a057ff3..09719f3 100644 --- a/LiteCharms.Infrastructure/Database/Migrations/LeadGeneratorDbContextModelSnapshot.cs +++ b/LiteCharms.Infrastructure/Database/Migrations/LeadGeneratorDbContextModelSnapshot.cs @@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LiteCharms.Infrastructure.Migrations { - [DbContext(typeof(LeadGeneratorDbContext))] + [DbContext(typeof(ShopDbContext))] partial class LeadGeneratorDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) diff --git a/LiteCharms.Infrastructure/Database/LeadGeneratorDbContext.cs b/LiteCharms.Infrastructure/Database/ShopDbContext.cs similarity index 85% rename from LiteCharms.Infrastructure/Database/LeadGeneratorDbContext.cs rename to LiteCharms.Infrastructure/Database/ShopDbContext.cs index b3e7195..91de689 100644 --- a/LiteCharms.Infrastructure/Database/LeadGeneratorDbContext.cs +++ b/LiteCharms.Infrastructure/Database/ShopDbContext.cs @@ -2,7 +2,7 @@ namespace LiteCharms.Infrastructure.Database; -public class LeadGeneratorDbContext(DbContextOptions options) : DbContext(options) +public class ShopDbContext(DbContextOptions options) : DbContext(options) { public DbSet Customers { get; set; } diff --git a/LiteCharms.Infrastructure/Database/ShopDbContextFactory.cs b/LiteCharms.Infrastructure/Database/ShopDbContextFactory.cs new file mode 100644 index 0000000..9de3cda --- /dev/null +++ b/LiteCharms.Infrastructure/Database/ShopDbContextFactory.cs @@ -0,0 +1,19 @@ +namespace LiteCharms.Infrastructure.Database; + +public class ShopDbContextFactory : IDesignTimeDbContextFactory +{ + public ShopDbContext CreateDbContext(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddUserSecrets(typeof(ShopDbContext).Assembly) + .AddJsonFile("appsettings.json") + .AddEnvironmentVariables() + .Build(); + + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseNpgsql(configuration.GetConnectionString("PostgresShop")); + + return new ShopDbContext(optionsBuilder.Options); + } +} diff --git a/LiteCharms.Infrastructure/HealthChecks/PostgresHealthCheck.cs b/LiteCharms.Infrastructure/HealthChecks/PostgresHealthCheck.cs index 6680c17..9cb5f03 100644 --- a/LiteCharms.Infrastructure/HealthChecks/PostgresHealthCheck.cs +++ b/LiteCharms.Infrastructure/HealthChecks/PostgresHealthCheck.cs @@ -2,7 +2,7 @@ public class PostgresHealthCheck(IConfiguration configuration) : IHealthCheck { - private readonly string connectionString = configuration.GetConnectionString("PostgresLeadGenerator")!; + private readonly string connectionString = configuration.GetConnectionString("PostgresShop")!; public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) {