private static async Task SeedDefaultDataAsync(IHost host) { using var scope = host.Services.CreateScope(); var context = scope.ServiceProvider.GetService <FeatureEntityDbContext>(); await context.Database.EnsureDeletedAsync(); await context.Database.EnsureCreatedAsync(); var featureMgmt = new FeatureManagement { Id = "1" }; var features = new SortedSet <Feature> { new Feature { Key = "MyFeatureA-1", Value = "true" }, new Feature { Key = "MyFeatureA-2", Value = "true" }, new Feature { Key = "MyFeatureB-1", Value = "false" }, new Feature { Key = "MyFeatureB-2", Value = "true" } }; featureMgmt.Features = features; await context.FeatureManagements.AddAsync(featureMgmt); await context.SaveChangesAsync(); }
public static void AddInvoicingServices( this IServiceCollection services, IConfiguration config, FeatureManagement features) { // Register PowerOffice if (features.UsePowerOffice) { services.Configure <PowerOfficeOptions>(config.GetSection("PowerOffice")); services.AddScoped <IPowerOfficeService, PowerOfficeService>(); } else { services.AddTransient <IPowerOfficeService, MockInvoicingService>(); } if (features.UseStripeInvoice) { var stripeConfig = config.GetSection("Stripe").Get <StripeOptions>(); StripeInvoicingService.Configure(stripeConfig.SecretKey); services.AddScoped <IStripeInvoiceService, StripeInvoicingService>(); } else { services.AddTransient <IStripeInvoiceService, MockInvoicingService>(); } }
public static void AddInvoicingServices( this IServiceCollection services, IConfiguration config, FeatureManagement features) { if (features.UsePowerOffice) { services.AddPowerOffice(config.GetSection("PowerOffice")); } if (features.UseStripeInvoice) { services.AddStripe(config.GetSection("Stripe")); } }