Ejemplo n.º 1
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, ShopSightContext shopsightContext)
        {
            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 http://go.microsoft.com/fwlink/?LinkID=532715

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

            DbInitializer.Initialize(shopsightContext);
        }
Ejemplo n.º 2
0
        public static void Initialize(ShopSightContext context)
        {
            context.Database.EnsureCreated();
            if (context.TaggedItems.Any())
            {
                return;
            }

            var items = new TaggedItem[]
            {
                new TaggedItem()
                {
                    ID           = "a001",
                    ImageUrl     = "/images/sample/a001.jpg",
                    Manufacturer = "Nordstrom",
                    Price        = (decimal)50.00,
                    SalePrice    = (decimal)48.00,
                    Title        = "Blue Shirt"
                },
                new TaggedItem()
                {
                    ID           = "a002",
                    ImageUrl     = "/images/sample/a002.jpg",
                    Manufacturer = "Giordano",
                    Price        = (decimal)60.00,
                    SalePrice    = (decimal)55.00,
                    Title        = "White Shirt"
                },
                new TaggedItem()
                {
                    ID           = "a003",
                    ImageUrl     = "/images/sample/a003.jpg",
                    Manufacturer = "Ralph Lauren",
                    Price        = (decimal)45.00,
                    SalePrice    = null,
                    Title        = "White Shirt"
                },
                new TaggedItem()
                {
                    ID           = "a004",
                    ImageUrl     = "/images/sample/a004.jpg",
                    Manufacturer = "Levis",
                    Price        = (decimal)30.00,
                    SalePrice    = (decimal)28.00,
                    Title        = "Blue Jeans"
                },
                new TaggedItem()
                {
                    ID           = "a005",
                    ImageUrl     = "/images/sample/a005.jpg",
                    Manufacturer = "Levis",
                    Price        = (decimal)40.00,
                    SalePrice    = (decimal)38.00,
                    Title        = "Tan Jeans"
                },
                new TaggedItem()
                {
                    ID           = "a006",
                    ImageUrl     = "/images/sample/a006.jpg",
                    Manufacturer = "Levis",
                    Price        = (decimal)999.00,
                    SalePrice    = (decimal)599.00,
                    Title        = "Coat"
                },
            };

            foreach (var item in items)
            {
                context.TaggedItems.Add(item);
            }

            context.SaveChanges();
        }
Ejemplo n.º 3
0
 public TagsController(ShopSightContext shopSightContext)
 {
     this.shopSightContext = shopSightContext;
 }