Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 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>();
     }
 }
Ejemplo n.º 3
0
        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"));
            }
        }