static void Main(string[] args) { Console.WriteLine("---------------------"); Console.WriteLine(" Build my inventory! "); Console.WriteLine("---------------------"); var seeder = new SeedRepository(); var task = new Task(async() => { await seeder.SeedBreads(); await seeder.SeedCheeses(); await seeder.SeedSauces(); await seeder.SeedSizes(); await seeder.SeedToppings(); }); task.Start(); Console.WriteLine("---------------------"); Console.WriteLine(" Done! "); Console.WriteLine("---------------------"); Console.ReadLine(); }
public CompanyControllerIntegrationTests() { var optionsBuilder = new DbContextOptionsBuilder <CompanyContext>(); string connectionString = "server=localhost;database=companydb_test;user=root;password=1234"; optionsBuilder.UseMySQL(connectionString); optionsBuilder.EnableSensitiveDataLogging(); CompanyContext context = new CompanyContext(optionsBuilder.Options); SeedRepository seedRepository = new SeedRepository(context); CompanyRepository companyRepository = new CompanyRepository(context); CompanyController = new CompanyController(companyRepository, seedRepository); context.Database.Migrate(); CompanyController.ClearData(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SeedRepository seedRepo) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(builder => { builder.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { await context.Response.WriteAsync(error.Error.Message); } }); }); // 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(); seedRepo.SeedUsers(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); app.UseAuthentication(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "ToolRenter API V1"); }); app.UseMvc(routes => { routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Fallback", action = "Index" } ); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SeedRepository seed) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseCors("CorsPolicy"); } app.UseRouting(); app.UseAuthorization(); seed.SeedData(20, 1000); app.UseMvc(routes => routes.MapRoute( "default", "api/{controller}/{action}/{id}" )); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
private static List <Category> GetSeedCategories() { var seedRepo = new SeedRepository(); return(seedRepo.GetSeedCategories()); //var result = new List<Category>() //{ // new Category // { // Name = "Benefit", // DisplayName = "Fundraisers & Benefits", // Description ="when it's all about helping a good cause", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name = "Gig", // DisplayName = "Gigs", // Description ="for local bands playing in local venues", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name="ArtistIndividual", // DisplayName = "Individual Artists", // Description ="for individual performers appearing alone or together", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name = "ArtistMultiple", // DisplayName = "Multiple Artists", // Description ="covers opening acts, joint appearances and/or special guests", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name="Series", // DisplayName = "Series", // Description ="when the event is part of a series", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name = "Exhibit", // DisplayName = "Exhibits", // Description ="Is your work going to be on display somewhere? choose this one!", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name = "Concert", // DisplayName = "Concert Tours", // Description ="for any show on tour: concerts, comedians, speakers, whatever", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name = "Orchestra", // DisplayName = "Troupes, Companies, Orchestras", // Description ="when who's putting on the show is as important as the show they're putting on", // Type = ListingCategory.Event, // Active = true // }, // new Category // { // Name="Other", // DisplayName = "Other", // Description ="any event that does not fall under any of the other categories, use this one!", // Type = ListingCategory.Event, // Active = true // }, // // Business Categories // new Category // { // Name="Artists", // DisplayName = "Artists, Artisans & Musicians", // Description ="If you create things of beauty, pick this one", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="HealthCare", // DisplayName = "Health Care", // Description ="For those who practice the healing arts and sciences (& have a degree AND/OR state certification)", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="AltHealthCare", // DisplayName = "Alternative Health Care", // Description ="For those with a non-traditional approach to addressing our aches and pains", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="Information", // DisplayName = "Information", // Description ="Do you offer information of any kind?", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="Instruction", // DisplayName = "Instruction", // Description ="Lessons and instruction of all kinds", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="Lawyers", // DisplayName = "Lawyers", // Description ="For practitioners of one of the world's oldest professions", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name = "Restaurant", // DisplayName = "Places to Eat", // Description ="Do you serve prepared food, ready to eat right now?", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="ServiceProviders", // DisplayName = "Service Providers", // Description ="For those who provide services people cannot or will not do for themselves (from walking dogs to building houses)", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="Shopkeepers", // DisplayName = "Shopkeepers", // Description ="If you sell (or rent out) stuff for a livelihood, choose this one, even if it's from out of your kitchen", // Type = ListingCategory.Business, // Active = true // }, // new Category // { // Name="Support", // DisplayName = "Support", // Description ="Do you offer support of any kind?", // Type = ListingCategory.Business, // Active = false // }, // new Category // { // Name="Other", // DisplayName = "Other", // Description ="any business that does not fall under the other categories, use this one!", // Type = ListingCategory.Business, // Active = true // } //}; //int displayCount = 1; //foreach (var item in result) //{ // item.DisplayOrder = displayCount; // displayCount++; //} //return result; }