Esempio n. 1
0
        public static void INIT(System.IServiceProvider serviceProvider)
        {
            var context = new DatabaseContext(serviceProvider.GetRequiredService <DbContextOptions <DatabaseContext> >());

            context.Database.EnsureCreated();
            InsertDefault(context);
        }
        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
            builder.UseSolutionRelativeContentRoot(Path.Combine("src", "OrderService", "OrderService.API"));

            builder.ConfigureServices(services =>
            {
                ConfigureServiceClients(services);

                // EFCore add DbContextOptions by `TryAdd`
                // and Startup's ConfigureServices is called before here
                // so we need to clean up previous options
                services.RemoveAll <DbContextOptions>();
                services.RemoveAll <DbContextOptions <OrderDbContext> >();

                ServiceProvider serviceProvider = new ServiceCollection()
                                                  .AddEntityFrameworkSqlite()
                                                  .BuildServiceProvider();
                services.AddDbContext <OrderDbContext>(options =>
                {
                    options.UseSqlite(_connection);
                    options.UseInternalServiceProvider(serviceProvider);
                });

                ServiceProvider sp = services.BuildServiceProvider();

                using IServiceScope scope = sp.CreateScope();
                System.IServiceProvider scopedServices = scope.ServiceProvider;
                OrderDbContext db = scopedServices.GetRequiredService <OrderDbContext>();
                db.Database.EnsureCreated();
            });
        }
Esempio n. 3
0
 protected virtual void EnsureDatabaseMigrations(IApplicationBuilder app)
 {
     using IServiceScope scope = app.ApplicationServices.CreateScope();
     System.IServiceProvider services = scope.ServiceProvider;
     try
     {
         BBBankContext context = services.GetRequiredService <BBBankContext>();
         context.Database.Migrate();
     }
     catch (System.Exception ex)
     {
         ILogger <Startup> logger = services.GetRequiredService <ILogger <Startup> >();
         logger.LogError(ex, "An error occured during database migration");
         throw;
     }
 }
        public static Cart GetCart(System.IServiceProvider services)
        {
            Microsoft.AspNetCore.Http.ISession session = services.GetRequiredService <Microsoft.AspNetCore.Http.IHttpContextAccessor>()?.HttpContext.Session;
            SessionCart cart = session?.GetJson <SessionCart>("Cart") ?? new SessionCart();

            cart.Session = session;
            return(cart);
        }
        //this is a method called CreateDbContext, returns an ApplicationDbContext object
        //where is this called?
        public ApplicationDbContext CreateDbContext(string[] args)
        {
            // Note that the BuilderWebHost method in the Program.cs is called on the next line
            Microsoft.AspNetCore.Hosting.IWebHost webHost = Program.BuildWebHost(args);
            System.IServiceProvider serviceProvider       = webHost.Services;
            ApplicationDbContext    applicationDbContext  = serviceProvider.GetRequiredService <ApplicationDbContext>();

            return(applicationDbContext);
        }
        protected virtual void EnsureDatabaseMigrations(IApplicationBuilder app)
        {
            using IServiceScope scope = app.ApplicationServices.CreateScope();
            System.IServiceProvider services = scope.ServiceProvider;

            AppContext context = services.GetRequiredService <AppContext>();

            context.Database.Migrate();

            DataSeeder.SeedData(context);
        }
        public Microsoft.Extensions.Hosting.IHostBuilder UseStartUp <T>()
        {
            System.Type startupType = typeof(T);

            this.m_hostServices.AddSingleton(typeof(IStartup), startupType);
            Microsoft.Extensions.Configuration.IConfiguration Configuration = this.m_configurationBuilder.Build();

            this.m_hostServices.Configure <Microsoft.Extensions.Configuration.IConfiguration>(Configuration);
            this.m_hostServices.AddSingleton <Microsoft.Extensions.Configuration.IConfiguration>(Configuration);


            System.IServiceProvider sp = this.m_hostServices.BuildServiceProvider();

            // Microsoft.Extensions.DependencyInjection.IServiceCollection services2 = Clone(this.m_hostServices);

            this.m_hostBuilder.ConfigureServices(
                (hostContext, services) =>
            {
                if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)
                {
                    services.AddHostedService <LinuxServiceHost>();
                }
                else
                {
                    // Inject concrete implementation of the service
                    services.AddSingleton(typeof(System.ServiceProcess.ServiceBase), typeof(GenericService));
                }
            }
                );


            this.m_startup = sp.GetRequiredService <IStartup>();

            this.m_hostBuilder.ConfigureServices(
                (hostContext, services) =>
            {
                services.AddSingleton <IStartup>(this.m_startup);
            }
                );


            this.m_hostBuilder.ConfigureServices((hostContext, services) =>
            {
                this.m_startup.ConfigureServices(services);
            });

            this.m_host = this.m_hostBuilder.Build();

            this.m_applicationBuilder = new ApplicationBuilder(this.m_host.Services);
            this.m_startup.Configure(this.m_applicationBuilder);

            return(this);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(ConfigurationConstants.APP_CULTURE);
            IWebHostBuilder builder = CreateWebHostBuilder(args);
            IWebHost        host    = builder.Build();

            using IServiceScope scope = host.Services.CreateScope();
            System.IServiceProvider services = scope.ServiceProvider;
            DatabaseContext         context  = services.GetRequiredService <DatabaseContext>();

            DatabaseInit.Execute(context);

            host.Run();
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, System.IServiceProvider services)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();
            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSwagger();
            app.UseSwaggerUI(options => {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "Lesenya Test API");
            });
            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });
            SeedData.SeedDatabase(services.GetRequiredService <DataContext>());
            IdentitySeedData.SeedDataBase(services).Wait();
        }
Esempio n. 10
0
        public async Task GetProfessions_ShouldReturnProfessions()
        {
            // Arrange
            System.IServiceProvider scope = _fx.GetScope();
            IDataRepo     service         = scope.GetRequiredService <IDataRepo>();
            List <string> expectedResult  = new List <string>()
            {
                "ABBOT", "GAMBLER", "PIT_FIGHTER", "SERGEANT"
            };

            // Act
            IEnumerable <string> result = await service.GetProfessionsAsync();

            // Assert
            Assert.Equal(expectedResult, result);
        }
Esempio n. 11
0
        public async Task GetProfession_ShouldReturnProfession(string professionId)
        {
            // Arrange
            System.IServiceProvider scope = _fx.GetScope();
            IDataRepo service             = scope.GetRequiredService <IDataRepo>();

            // Act
            Profession result = await service.GetProfessionAsync(professionId);

            // Assert
            Assert.Equal(professionId, result.Id);
            Assert.False(result.IsAdvanced);
            Assert.Equal("profession-description", result.Description);
            Assert.Equal("profession-label", result.Label);
            Assert.Equal(100, result.MainProfile.Ws);
            Assert.Equal(100, result.SecondaryProfile.A);
            Assert.Equal(2, result.NumberOfAdvances);
        }
Esempio n. 12
0
        public static void EnsureSeedData(IApplicationBuilder app)
        {
            //var services = new ServiceCollection();
            //services.AddOperationalDbContext(options =>
            //{
            //    options.ConfigureDbContext = db => db.UseSqlite(connectionString, sql => sql.MigrationsAssembly(typeof(SeedData).Assembly.FullName));
            //});
            //services.AddConfigurationDbContext(options =>
            //{
            //    options.ConfigureDbContext = db => db.UseSqlite(connectionString, sql => sql.MigrationsAssembly(typeof(SeedData).Assembly.FullName));
            //});

            System.IServiceProvider serviceProvider = app.ApplicationServices;

            using (var scope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                scope.ServiceProvider.GetService <PersistedGrantDbContext>().Database.Migrate();

                var context = scope.ServiceProvider.GetService <ConfigurationDbContext>();
                context.Database.Migrate();
                EnsureSeedData(context);
            }
        }
Esempio n. 13
0
 public void should_be_able_to_resolve_indexers()
 {
     _container.GetRequiredService <IEnumerable <IIndexer> >().Should().NotBeEmpty();
 }
Esempio n. 14
0
 public static void Initialize(System.IServiceProvider serviceProvider)
 {
     using (var context = new DataContext(
                opts: serviceProvider.GetRequiredService <DbContextOptions <DataContext> >()))
     {
         if (!context.Database.EnsureCreated())
         {
             var s1 = new Supplier
             {
                 Name  = "Splash Dudes",
                 City  = "San Jose",
                 State = "CA"
             };
             var s2 = new Supplier
             {
                 Name  = "Soccer Town",
                 City  = "Chicago",
                 State = "IL"
             };
             var s3 = new Supplier
             {
                 Name  = "Chess Co",
                 City  = "New York",
                 State = "NY"
             };
             context.Products.AddRange(
                 new Product
             {
                 Name        = "Kayak",
                 Description = "A boat for one person",
                 Category    = "Watersports",
                 Price       = 275,
                 Supplier    = s1,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 4
                     }, new Rating {
                         Stars = 3
                     }
                 }
             },
                 new Product
             {
                 Name        = "Lifejacket",
                 Description = "Protective and fashionable",
                 Category    = "Watersports",
                 Price       = 48.95m,
                 Supplier    = s1,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 2
                     }, new Rating {
                         Stars = 5
                     }
                 }
             },
                 new Product
             {
                 Name        = "Soccer Ball",
                 Description = "FIFA-approved size and weight",
                 Category    = "Soccer",
                 Price       = 19.50m,
                 Supplier    = s2,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 1
                     }, new Rating {
                         Stars = 3
                     }
                 }
             },
                 new Product
             {
                 Name        = "Corner Flags",
                 Description = "Give your pitch a professional touch",
                 Category    = "Soccer",
                 Price       = 34.95m,
                 Supplier    = s2,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 3
                     }
                 }
             },
                 new Product
             {
                 Name        = "Stadium",
                 Description = "Flat-packed 35,000-seat stadium",
                 Category    = "Soccer",
                 Price       = 79500,
                 Supplier    = s2,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 1
                     },
                     new Rating {
                         Stars = 4
                     }, new Rating {
                         Stars = 3
                     }
                 }
             },
                 new Product
             {
                 Name        = "Thinking Cap",
                 Description = "Improve brain efficiency by 75%",
                 Category    = "Chess",
                 Price       = 16,
                 Supplier    = s3,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 5
                     },
                     new Rating {
                         Stars = 4
                     }
                 }
             },
                 new Product
             {
                 Name        = "Unsteady Chair",
                 Description = "Secretly give your opponent a disadvantage",
                 Category    = "Chess",
                 Price       = 29.95m,
                 Supplier    = s3,
                 Ratings     = new List <Rating> {
                     new Rating {
                         Stars = 3
                     }
                 }
             },
                 new Product
             {
                 Name        = "Human Chess Board",
                 Description = "A fun game for the family",
                 Category    = "Chess",
                 Price       = 75,
                 Supplier    = s3
             },
                 new Product
             {
                 Name        = "Bling-Bling King",
                 Description = "Gold-plated, diamond-studded King",
                 Category    = "Chess",
                 Price       = 1200,
                 Supplier    = s3
             });
             context.SaveChanges();
         }
     }
 }
Esempio n. 15
0
        public static void Seed(System.IServiceProvider applicationBuilder)
        {
            AppDbContext context =
                applicationBuilder.GetRequiredService <AppDbContext>();

            if (!context.Categories.Any())
            {
                context.Categories.AddRange(Categories.Select(c => c.Value));
            }

            if (!context.Drinks.Any())
            {
                context.AddRange
                (
                    new Drink {
                    Name              = "Beer",
                    Price             = 7.95M, ShortDescription = "The most widely consumed alcohol",
                    LongDescription   = "Beer is the world's oldest[1][2][3] and most widely consumed[4] alcoholic drink; it is the third most popular drink overall, after water and tea.[5] The production of beer is called brewing, which involves the fermentation of starches, mainly derived from cereal grains—most commonly malted barley, although wheat, maize (corn), and rice are widely used.[6] Most beer is flavoured with hops, which add bitterness and act as a natural preservative, though other flavourings such as herbs or fruit may occasionally be included. The fermentation process causes a natural carbonation effect, although this is often removed during processing, and replaced with forced carbonation.[7] Some of humanity's earliest known writings refer to the production and distribution of beer: the Code of Hammurabi included laws regulating beer and beer parlours.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/beerL_2.jpg",
                    InStock           = true,
                    IsPreferredDrink  = true,
                    ImageThumbnailUrl = "http://imgh.us/beerS_1.jpeg"
                },
                    new Drink {
                    Name              = "Rum & Coke",
                    Price             = 12.95M, ShortDescription = "Cocktail made of cola, lime and rum.",
                    LongDescription   = "The world's second most popular drink was born in a collision between the United States and Spain. It happened during the Spanish-American War at the turn of the century when Teddy Roosevelt, the Rough Riders, and Americans in large numbers arrived in Cuba. One afternoon, a group of off-duty soldiers from the U.S. Signal Corps were gathered in a bar in Old Havana. Fausto Rodriguez, a young messenger, later recalled that Captain Russell came in and ordered Bacardi (Gold) rum and Coca-Cola on ice with a wedge of lime. The captain drank the concoction with such pleasure that it sparked the interest of the soldiers around him. They had the bartender prepare a round of the captain's drink for them. The Bacardi rum and Coke was an instant hit. As it does to this day, the drink united the crowd in a spirit of fun and good fellowship. When they ordered another round, one soldier suggested that they toast ¡Por Cuba Libre! in celebration of the newly freed Cuba.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/rumCokeL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/rumAndCokeS.jpg"
                },
                    new Drink {
                    Name              = "Tequila ",
                    Price             = 12.95M, ShortDescription = "Beverage made from the blue agave plant.",
                    LongDescription   = "Tequila (Spanish About this sound [teˈkila] (help·info)) is a regionally specific name for a distilled beverage made from the blue agave plant, primarily in the area surrounding the city of Tequila, 65 km (40 mi) northwest of Guadalajara, and in the highlands (Los Altos) of the central western Mexican state of Jalisco. Although tequila is similar to mezcal, modern tequila differs somewhat in the method of its production, in the use of only blue agave plants, as well as in its regional specificity. Tequila is commonly served neat in Mexico and as a shot with salt and lime across the rest of the world.The red volcanic soil in the surrounding region is particularly well suited to the growing of the blue agave, and more than 300 million of the plants are harvested there each year.[1] Agave tequila grows differently depending on the region. Blue agaves grown in the highlands Los Altos region are larger in size and sweeter in aroma and taste. Agaves harvested in the lowlands, on the other hand, have a more herbaceous fragrance and flavor.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/tequilaL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/tequilaS.jpg"
                },
                    new Drink
                {
                    Name              = "Wine ",
                    Price             = 16.75M,
                    ShortDescription  = "A very elegant alcoholic drink",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/wineL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/wineS.jpg"
                },
                    new Drink
                {
                    Name              = "Margarita",
                    Price             = 17.95M,
                    ShortDescription  = "A cocktail with sec, tequila and lime",
                    Category          = Categories["Alcoholic"],
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    ImageUrl          = "http://imgh.us/margaritaL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/margaritaS.jpg"
                },
                    new Drink {
                    Name              = "Whiskey with Ice",
                    Price             = 15.95M, ShortDescription = "The best way to taste whiskey",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/whiskyIceL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/whiskeyS.jpg"
                },
                    new Drink
                {
                    Name              = "Jägermeister",
                    Price             = 15.95M,
                    ShortDescription  = "A German digestif made with 56 herbs",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/jagermeisterL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/jagermeisterS.jpg"
                },
                    new Drink
                {
                    Name              = "Champagne",
                    Price             = 15.95M,
                    ShortDescription  = "That is how sparkling wine can be called",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/champagneL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/champagneS.jpg"
                },
                    new Drink
                {
                    Name              = "Piña colada ",
                    Price             = 15.95M,
                    ShortDescription  = "A sweet cocktail made with rum.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/pinaColadaL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/pinaColadaS.jpg"
                },
                    new Drink
                {
                    Name              = "White Russian",
                    Price             = 15.95M,
                    ShortDescription  = "A cocktail made with vodka ",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/whiteRussianL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/whiteRussianS.jpg"
                },
                    new Drink
                {
                    Name              = "Long Island Iced Tea",
                    Price             = 15.95M,
                    ShortDescription  = "Aa mixed drink made with tequila.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/longTeaL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/islandTeaS.jpg"
                },
                    new Drink
                {
                    Name              = "Vodka",
                    Price             = 15.95M,
                    ShortDescription  = "A distilled beverage with water and ethanol.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/vodkaL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/vodkaS.jpg"
                },
                    new Drink
                {
                    Name              = "Gin and tonic",
                    Price             = 15.95M,
                    ShortDescription  = "Made with gin and tonic water poured over ice.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/ginTonicL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/ginTonicS.jpg"
                },
                    new Drink
                {
                    Name              = "Cosmopolitan",
                    Price             = 15.95M,
                    ShortDescription  = "Made with vodka, triple sec, cranberry juice.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Alcoholic"],
                    ImageUrl          = "http://imgh.us/cosmopolitanL.jpg",
                    InStock           = false,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/cosmopolitanS.jpg"
                },
                    new Drink {
                    Name              = "Tea ",
                    Price             = 12.95M,
                    ShortDescription  = "Made by leaves of the tea plant in hot water.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Non-alcoholic"],
                    ImageUrl          = "http://imgh.us/teaL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = true,
                    ImageThumbnailUrl = "http://imgh.us/teaS.jpg"
                },
                    new Drink
                {
                    Name              = "Water ",
                    Price             = 12.95M,
                    ShortDescription  = " It makes up more than half of your body weight ",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Non-alcoholic"],
                    ImageUrl          = "http://imgh.us/waterL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/waterS_1.jpg"
                },
                    new Drink
                {
                    Name              = "Coffee ",
                    Price             = 12.95M,
                    ShortDescription  = " A beverage prepared from coffee beans",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Non-alcoholic"],
                    ImageUrl          = "http://imgh.us/coffeeL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = true,
                    ImageThumbnailUrl = "http://imgh.us/coffeS.jpg"
                },
                    new Drink
                {
                    Name              = "Kvass",
                    Price             = 12.95M,
                    ShortDescription  = "A very refreshing Russian beverage",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Non-alcoholic"],
                    ImageUrl          = "http://imgh.us/kvassL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/kvassS.jpg"
                },
                    new Drink
                {
                    Name              = "Juice ",
                    Price             = 12.95M,
                    ShortDescription  = "Naturally contained in fruit or vegetable tissue.",
                    LongDescription   = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.",
                    Category          = Categories["Non-alcoholic"],
                    ImageUrl          = "http://imgh.us/juiceL.jpg",
                    InStock           = true,
                    IsPreferredDrink  = false,
                    ImageThumbnailUrl = "http://imgh.us/juiceS.jpg"
                }
                );
            }

            context.SaveChanges();
        }
Esempio n. 16
0
 public SomeExpensiveService(System.IServiceProvider sp, string name)
 {
     _logger = sp.GetRequiredService <ILogger <SomeExpensiveService> >();
     _name   = name;
     _logger.LogDebug($"Constructor {name}");
 }
Esempio n. 17
0
        // this method does not return anything
        // this method is called by passing in a parameter called 'app' which is of type ApplicationDbContext.
        public static void EnsurePopulated(System.IServiceProvider services)
        {
            ApplicationDbContext context = services.GetRequiredService <ApplicationDbContext>();

            //context.Database.Migrate();
            //DbSet<ProductCategory> productCategories = context.ProductCategories;
            //if (!productCategories.Any())
            //{
            //    var cueProducts = new ProductCategory{Category = "Cues", Description = "We have the best cues."};
            //    var tableProducts = new ProductCategory { Category = "Tables", Description = "We have the best tables." };
            //    var ballProducts = new ProductCategory { Category = "Balls", Description = "We have the best balls."};
            //    context.ProductCategories.Add(cueProducts);
            //    context.ProductCategories.Add(tableProducts);
            //    context.ProductCategories.Add(ballProducts);
            if (!context.Products.Any())
            {
                {
                    var product = new Product
                    {
                        Name        = "Predator 8K-1 Pool Cue",
                        Description = "Predator 8K-1 is constructed from Black Hard Canadian Maple with custom Silver and Micarta Rings. Completing cue is a Uni-Loc joint and black Leather Luxe wrap.",
                        //         ProductCategoryID = 1,
                        Category          = "Cues",
                        Price             = 639.00m,
                        ImageUrlMain      = "../images/cues/predator/pre8k01_01.jpg",
                        ImageUrlSecondary = "../images/cues/predator/8k1_2.jpg",
                        ImageUrlOptional  = "../images/cues/predator/8k1_3.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "M29B G204 Pool Cue",
                        Description = "McDermott Pool Cue model G204 has a Birdseye Maple forearm and sleeve with American Cherry European organic stain and German brass rings. The McDermott G204 comes standard with the G-Core shaft.",
                        //         ProductCategoryID = 1,
                        Category          = "Cues",
                        Price             = 252.00m,
                        ImageUrlMain      = "../images/cues/mcdermott/g204_1.jpg",
                        ImageUrlSecondary = "../images/cues/mcdermott/g204_3.jpg",
                        ImageUrlOptional  = "../images/cues/mcdermott/g204_2.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Predator BK RUSH Break Cue Sport Wrap",
                        Description = "Predator BK RUSH Sports wrap Break Cue. The all-new BK-Rush high-performance break cue combines Predator’s proven BK technology with an optimized REVO carbon fiber composite shaft developed for breaking. Featuring a four-piece fused construction butt that is break balanced to deliver more power with less effort, and a REVO BK-R carbon fiber composite break shaft developed to transfer that raw power with the accuracy of a playing shaft. The Predator BK-Rush is our most powerful break cue, it simply obliterates the competition.",
                        //         ProductCategoryID = 1,
                        Category          = "Cues",
                        Price             = 709.00m,
                        ImageUrlMain      = "../images/cues/break/prebkrw_1.jpg",
                        ImageUrlSecondary = "../images/cues/break/prebkrw_cat.jpg",
                        ImageUrlOptional  = "../images/cues/break/bkrush-tech-1-frontend-final-(1)_bs.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Diamond Pool Tables - 7ft Pro-Am Pool Table - Oak Walnut",
                        Description = "Oak with Walnut Finish 7 Foot Diamond Billiards Pro-Am pool table. The PRO-AM is the highest grade commercial quality table Diamond offers. It is an extremely quiet ball return table that includes all the same features and playability of the DIAMOND PROFESSIONAL. The PRO-AM is superior in terms of construction, quality, and materials, but most importantly, it's playability is second to none.",
                        //        ProductCategoryID = 2,
                        Category          = "Tables",
                        Price             = 4900.00m,
                        ImageUrlMain      = "../images/tables/walnut/7proamow_1533243658_850_walnut_tournament_blue.jpg",
                        ImageUrlSecondary = "../images/tables/walnut/black_logo.jpg",
                        ImageUrlOptional  = "../images/tables/walnut/walnut_full_size.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Diamond Pool Tables - 7ft Pro-Am Pool Table - Rosewood Dymalux",
                        Description = "Rosewood Dymalux 7 Foot Diamond Billiards Pro-Am pool table. The PRO-AM is the highest grade commercial quality table Diamond offers. It is an extremely quiet ball return table that includes all the same features and playability of the DIAMOND PROFESSIONAL. The PRO-AM is superior in terms of construction, quality, and materials, but most importantly, it's playability is second to none.",
                        //         ProductCategoryID = 2,
                        Category     = "Tables",
                        Price        = 4900.00m,
                        ImageUrlMain = "../images/tables/cherry/7proamrprc_1543616344_cherry_dymalux.jpg"
                                       // ImageUrlSecondary = "../images/tables/cherry/8k1.jpg",
                                       // ImageUrlOptional = "../images/tables/cherry/8k1-1.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Diamond Pool Tables - 7ft Pro-Am Pool Table - Charcoal Dymalux",
                        Description = "Charcoal Dymalux 7 Foot Diamond Billiards Pro-Am pool table. This table had black legs with charcoal Dymalux rails. The PRO-AM is the highest grade commercial quality table Diamond offers. It is an extremely quiet ball return table that includes all the same features and playability of the DIAMOND PROFESSIONAL. The PRO-AM is superior in terms of construction, quality, and materials, but most importantly, it's playability is second to none.",
                        //          ProductCategoryID = 2,
                        Category     = "Tables",
                        Price        = 4900.00m,
                        ImageUrlMain = "../images/tables/charcoal/7proamchprc_1543613363_charcoal_dymalux_850.jpg"
                                       // ImageUrlSecondary = "../images/tables/charcoal/8k1.jpg",
                                       //  ImageUrlOptional = "../images/tables/charcoal/8k1-1.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Aramith Standard Pool Ball Set",
                        Description = "Aramith Standard Belgian billiard ball sets have all of the standard quality's you would expect from an Aramith billiard ball without having to pay the high price of their designer sets. The standard Aramith balls are perfectly round and balanced billiard balls with uniform weight and hardness.",
                        //        ProductCategoryID = 3,
                        Category          = "Balls",
                        Price             = 95.58m,
                        ImageUrlMain      = "../images/balls/ar1046/ar1046.jpg",
                        ImageUrlSecondary = "../images/balls/ar1046/66.jpg",
                        ImageUrlOptional  = "../images/balls/ar1046/67.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "TV Pro Cup Pool Ball Set",
                        Description = "Super Aramith pro TV ball set are constructed from Professional grade Aramith phenolic resin designed in Aramith laboratories. The balls are known for their hardened vitrified surface with ultra-high density for exceptional scratch and impact resistance. Aramith high quality standard have to meet these 8 criteria ball density, balance, diameter, roundness, color, glossiness, hardness, and weight to be Aramith ball.",
                        //          ProductCategoryID = 3,
                        Category     = "Balls",
                        Price        = 269.02m,
                        ImageUrlMain = "../images/balls/ar1040/ar1040.jpg",
                        //  ImageUrlSecondary = "../images/balls/ar1040/8k1.jpg",
                        //  ImageUrlOptional = "../images/balls/ar1040/8k1-1.jpg"
                    };
                    context.Products.Add(product);

                    product = new Product
                    {
                        Name        = "Cyclop Ares Traditional Color Pool Ball set",
                        Description = "Cyclop Ares traditional color ball set. Cyclop balls are in many pro tournaments world wide and highly sought after by any player that wants the best. The Cyclop balls are constructed of highly configured Phenolic resin allowing for durability while keeping their shine and color longer than the standard pool balls.",
                        //          ProductCategoryID = 3,
                        Category          = "Balls",
                        Price             = 199.00m,
                        ImageUrlMain      = "../images/balls/cybs/cycbs-a_1512054185_cyclop_ares_850.jpg",
                        ImageUrlSecondary = "../images/balls/cybs/cyclop_ares_balls.jpg"
                                            //  ImageUrlOptional = "../images/balls/cybs/8k1-1.jpg"
                    };
                    context.Products.Add(product);

                    context.SaveChanges();
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Renders the beginning &lt;form&gt; tag with the specified attributes.
        /// </summary>
        /// <param name="HtmlAttributes">The HTML attributes to add to the &lt;form&gt; tag.</param>
        /// <param name="SaveReturnUrl">Defines whether the return URL is saved when the form is submitted.</param>
        /// <param name="ValidateImmediately">Defines whether client-side validation is immediate (true) or delayed until form submission (false).</param>
        /// <param name="ActionName">Overrides the default action name.</param>
        /// <param name="ControllerName">Overrides the default controller name.</param>
        /// <param name="Pure">TODO: Purpose unclear.</param>
        /// <param name="Method">The method used to submit the form (get/post)</param>
        /// <returns>Returns the HTML with the generated &lt;form&gt; tag.</returns>
        protected async Task <string> RenderBeginFormAsync(object HtmlAttributes = null, bool SaveReturnUrl = false, bool ValidateImmediately = false, string ActionName = null, string ControllerName = null, string Method = "post")
        {
            await YetaWFCoreRendering.Render.AddFormsAddOnsAsync();

            await Manager.AddOnManager.AddAddOnNamedAsync("YetaWF_Core", "Forms");// standard css, validation strings

            await Manager.AddOnManager.AddAddOnNamedAsync("YetaWF_ComponentsHTML", "Forms");

            Manager.ScriptManager.AddLast("$YetaWF.Forms", "$YetaWF.Forms;");// need to evaluate for side effect to initialize forms

            Manager.NextUniqueIdPrefix();

            if (string.IsNullOrWhiteSpace(ActionName))
            {
                ActionName = GetViewName();
            }
            if (!ActionName.EndsWith(YetaWFViewExtender.PartialSuffix))
            {
                ActionName += YetaWFViewExtender.PartialSuffix;
            }
            if (string.IsNullOrWhiteSpace(ControllerName))
            {
                ControllerName = ModuleBase.Controller;
            }

            IDictionary <string, object> rvd = YHtmlHelper.AnonymousObjectToHtmlAttributes(HtmlAttributes);

            if (SaveReturnUrl)
            {
                rvd.Add(Basics.CssSaveReturnUrl, "");
            }

            string css = null;

            if (Manager.CurrentSite.FormErrorsImmed)
            {
                css = CssManager.CombineCss(css, "yValidateImmediately");
            }
            css = CssManager.CombineCss(css, Forms.CssFormAjax);
            rvd.Add("class", css);

            YTagBuilder tagBuilder = new YTagBuilder("form");

            tagBuilder.MergeAttributes(rvd, true);
            if (ModuleBase.FormAutoComplete)
            {
                tagBuilder.Attributes.Add("autocomplete", "on");
            }
            else
            {
                tagBuilder.Attributes.Add("autocomplete", "new-password");
            }

            string id = null;

            if (tagBuilder.Attributes.ContainsKey("id"))
            {
                id = (string)tagBuilder.Attributes["id"];
            }
            else
            {
                id = Manager.UniqueId();
                tagBuilder.Attributes.Add("id", id);
            }
            string formAction;

#if MVC6
            System.IServiceProvider services = HtmlHelper.ActionContext.HttpContext.RequestServices;
            IUrlHelper urlHelper             = services.GetRequiredService <IUrlHelperFactory>().GetUrlHelper(HtmlHelper.ActionContext);
            formAction = urlHelper.Action(action: ActionName, controller: ControllerName, new { area = HtmlHelper.RouteData.Values["area"] });
#else
            formAction = UrlHelper.GenerateUrl(null /* routeName */, ActionName, ControllerName, null, RouteTable.Routes, HtmlHelper.RequestContext, true /* includeImplicitMvcValues */);
#endif
            tagBuilder.MergeAttribute("action", formAction, true);
            tagBuilder.MergeAttribute("method", Method, true);

            // show errors if already present
            if (!HtmlHelper.ModelState.IsValid)
            {
                Manager.ScriptManager.AddLast($@"
var f = $YetaWF.getElementById('{id}');
if ($YetaWF.Forms.hasErrors(f))
    $YetaWF.Forms.showErrors(f);
");
            }

            return(tagBuilder.ToString(YTagRenderMode.StartTag));
        }
    public static void Initialize(System.IServiceProvider serviceProvider)
    {
        using (var context = new MontadorasGameContext(
                   serviceProvider.GetRequiredService <DbContextOptions <MontadorasGameContext> >()))
        {
            List <Resposta> respostas1 = new List <Resposta>();
            List <Resposta> respostas2 = new List <Resposta>();
            List <Resposta> respostas3 = new List <Resposta>();
            List <Resposta> respostas4 = new List <Resposta>();
            List <Resposta> respostas5 = new List <Resposta>();

            respostas1.AddRange(new List <Resposta>()
            {
                new Resposta {
                    Id = 1, Descricao = "Inglaterra", EhCerta = false
                },
                new Resposta {
                    Id = 2, Descricao = "USA", EhCerta = false
                },
                new Resposta {
                    Id = 3, Descricao = "Alemanha", EhCerta = true
                },
                new Resposta {
                    Id = 4, Descricao = "Japão", EhCerta = false
                },
            });

            respostas2.AddRange(new List <Resposta>()
            {
                new Resposta {
                    Id = 5, Descricao = "Inglaterra", EhCerta = false
                },
                new Resposta {
                    Id = 6, Descricao = "USA", EhCerta = false
                },
                new Resposta {
                    Id = 7, Descricao = "Alemanha", EhCerta = false
                },
                new Resposta {
                    Id = 8, Descricao = "Japão", EhCerta = true
                },
            });

            respostas3.AddRange(new List <Resposta>()
            {
                new Resposta {
                    Id = 9, Descricao = "Inglaterra", EhCerta = true
                },
                new Resposta {
                    Id = 10, Descricao = "USA", EhCerta = false
                },
                new Resposta {
                    Id = 11, Descricao = "Alemanha", EhCerta = false
                },
                new Resposta {
                    Id = 12, Descricao = "Japão", EhCerta = false
                },
            });

            respostas4.AddRange(new List <Resposta>()
            {
                new Resposta {
                    Id = 13, Descricao = "Inglaterra", EhCerta = false
                },
                new Resposta {
                    Id = 14, Descricao = "USA", EhCerta = true
                },
                new Resposta {
                    Id = 15, Descricao = "Alemanha", EhCerta = false
                },
                new Resposta {
                    Id = 16, Descricao = "Japão", EhCerta = false
                },
            });

            respostas5.AddRange(new List <Resposta>()
            {
                new Resposta {
                    Id = 17, Descricao = "Inglaterra", EhCerta = true
                },
                new Resposta {
                    Id = 18, Descricao = "USA", EhCerta = false
                },
                new Resposta {
                    Id = 19, Descricao = "Alemanha", EhCerta = false
                },
                new Resposta {
                    Id = 20, Descricao = "Japão", EhCerta = false
                },
            });

            context.Pergunta.AddRange(
                new Pergunta {
                Id = 1, Descricao = "Qual o país de origem da BMW?", Respostas = respostas1
            },
                new Pergunta {
                Id = 2, Descricao = "Qual o país de origem da Toyota?", Respostas = respostas2
            },
                new Pergunta {
                Id = 3, Descricao = "Qual o país de origem da Mini?", Respostas = respostas3
            },
                new Pergunta {
                Id = 4, Descricao = "Qual o país de origem da General Motors?", Respostas = respostas4
            },
                new Pergunta {
                Id = 5, Descricao = "Qual o país de origem da Rolls-Royce?", Respostas = respostas5
            }
                );

            context.SaveChanges();
        }
    }