Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductsRepository"/> class.
 /// </summary>
 public ProductsRepository(IDbConnectionFactory dbConnectionFactory, IOptions <AppSettings> options)
 {
     _storage = new AcmeContext(dbConnectionFactory);
     redisConnectionString = options.Value.RedisConnectionString;
     searchServiceName     = options.Value.SearchServiceName;
     searchApikey          = options.Value.SearchAPIKey;
 }
Example #2
0
        /// <summary>
        /// Ensures the database is seeded.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public static int EnsureDatabaseIsSeeded(this IApplicationBuilder builder, IOptions <AppSettings> options)
        {
            IDbConnectionFactory connectionFactory = builder.ApplicationServices.GetService(typeof(IDbConnectionFactory)) as IDbConnectionFactory;
            var context = new Repositories.AcmeContext(connectionFactory);

            context.Database.EnsureCreated();
            return(context.EnsureSeedData(options.Value.RedisConnectionString));
        }