public static void Initialize(SouthSeaContext context)
        {
            context.Database.EnsureCreated();

            //if (!context.Merchandise.Any())
            //{

            //    // if the there is an ID in the context (DB) return and don't procced with Init method
            //    return ;
            //}

            var merchandise = new Merchandise[] {
                new  Merchandise
                {
                    ItemName    = "Jade Necklace",
                    Description = "Necklace",
                    Type        = "Jade",
                    Image       = "C:\\Users\\Thaddeus\\Documents\\" +
                                  "Visual Studio 2017\\Projects\\SouthSea\\SouthSea\\wwwroot\\" +
                                  "images\\Merchandise\\TestItemIMG.jpg",
                    Date = DateTime.Now,
                    //GemStones = new Models.GemStone {ID=1, TypeStone="Carnilian Stone"},
                    Length = 1,
                    Weight = 1,
                    Price  = 45.00m
                }
            };

            foreach (var m in merchandise)
            {
                context.Merchandise.Add(m);
            }

            context.SaveChanges();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, SouthSeaContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });


            //GemStoneInitializer.Initialize(context);
            //MerchendiseInitializer.Initialize(context);
        }
Beispiel #3
0
 public CustomersController(SouthSeaContext context)
 {
     _context = context;
 }
 public MerchandisesController(SouthSeaContext context, IHostingEnvironment env)
 {
     _context    = context;
     environment = env;
 }
        public static void Initialize(SouthSeaContext context)
        {
            //if (!context.GemStone.Equals(null))
            //{
            //    return;
            //}


            var gems = new GemStone[]

            {
                new GemStone
                {
                    TypeStone = "Carnilian Stone"
                },

                new GemStone
                {
                    TypeStone = "Hematites with Coral"
                },
                new GemStone
                {
                    TypeStone = "Blue Moon Stone"
                },

                new GemStone
                {
                    TypeStone = "Amethyst Stone"
                },
                new GemStone
                {
                    TypeStone = "Cherry Squarts"
                },

                new GemStone
                {
                    TypeStone = "Hematites with Turkoys"
                },

                new GemStone
                {
                    TypeStone = "Hematites with Pearl"
                },
                new GemStone
                {
                    TypeStone = "Tiger Eye"
                },
                new GemStone
                {
                    TypeStone = "Black Pearl"
                },
                new GemStone
                {
                    TypeStone = "Turquios"
                },
                new GemStone
                {
                    TypeStone = "Morano Stones"
                },
                new GemStone
                {
                    TypeStone = "Rose Squarts"
                },
                new GemStone
                {
                    TypeStone = "Sun Stones"
                },
                new GemStone
                {
                    TypeStone = "Red Corals"
                },
                new GemStone
                {
                    TypeStone = "Whole Light"
                },
                new GemStone
                {
                    TypeStone = "Black & White Pearls"
                },
                new GemStone
                {
                    TypeStone = "Puka Shell"
                },
                new GemStone
                {
                    TypeStone = "Moon Stone"
                },
                new GemStone
                {
                    TypeStone = "Jade"
                }
            };

            foreach (var g in gems)
            {
                context.GemStone.Add(g);
            }

            context.SaveChanges();
        }