public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService <DbContextOptions <MegaDeskWebContext> >())) { // Look for any movies. if (context.Quote.Any()) { return; // DB has been seeded } context.SaveChanges(); } }
public CreateModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; IQueryable <string> matQuery = from m in _context.SurfaceMaterial orderby m.SurfaceMaterialName select m.SurfaceMaterialName; SurfaceMaterials = new SelectList(matQuery.Distinct().ToList()); IQueryable <string> deliQuery = from d in _context.Delivery orderby d.DeliveryName select d.DeliveryName; Deliverys = new SelectList(deliQuery.Distinct().ToList()); }
public EditModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; IQueryable <string> surfaceMaterialQuery = from m in _context.SurfaceMaterial orderby m.SurfaceMaterialName select m.SurfaceMaterialName; IQueryable <string> shippingTypeQuery = from m in _context.Shipping orderby m.ShippingType select m.ShippingType; SurfaceMaterialList = new SelectList(surfaceMaterialQuery.Distinct().ToList()); ShippingList = new SelectList(shippingTypeQuery.Distinct().ToList()); }
// Methods public decimal GetQuotePrice(MegaDeskWebContext context) { // Return Value decimal quotePrice = BASE_DESK_PRICE; // Surface Area decimal surfaceArea = this.Desk.Depth * this.Desk.Width; // Surface Price decimal surfacePrice = 0.00M; if (surfaceArea > 1000) { surfacePrice = (surfaceArea - 1000) * SURFACE_AREA_COST; } // Drawers decimal drawerPrice = this.Desk.NumberOfDrawers * DRAWER_COST; // Surface Materials decimal surfaceMaterialPrice = 0.00M; var surfaceMaterialPrices = context.DesktopMaterial .Where(d => d.DesktopMaterialId == this.Desk.DesktopMaterialId).FirstOrDefault(); surfaceMaterialPrice = surfaceMaterialPrices.Cost; // Shipping decimal shippingPrice = 0.00M; var shippingPrices = context.Delivery.Where(d => d.DeliveryId == this.DeliveryTypeId).FirstOrDefault(); if (surfaceArea < 1000) { shippingPrice = shippingPrices.PriceUnder1000; } else if (surfaceArea > 1000 && surfaceArea < 2000) { shippingPrice = shippingPrices.PriceBetween1000And2000; } else { shippingPrice = shippingPrices.PriceOver2000; } quotePrice += surfacePrice = drawerPrice + surfaceMaterialPrice + shippingPrice; return(quotePrice); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService < DbContextOptions <MegaDeskWebContext> >())) { // Look for any movies. if (context.Material.Any()) { return; // DB has been seeded } context.Material.AddRange( new Material { MaterialType = "Oak", MaterialPrice = 200 }, new Material { MaterialType = "Laminate", MaterialPrice = 100 }, new Material { MaterialType = "Pine", MaterialPrice = 50 }, new Material { MaterialType = "Rose Wood", MaterialPrice = 300 }, new Material { MaterialType = "Veneer", MaterialPrice = 125 } ); context.SaveChanges(); } }
public IndexModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; }
public DeleteModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; }
public EditModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; }
public DetailsModel(MegaDeskWeb.Models.MegaDeskWebContext context) { _context = context; }
public static void Initialize(MegaDeskWebContext context) { if (context.RushShipping.Any()) { return; //DB is already seeded. } var shippingPrices = new RushShipping[] { new RushShipping { RushShippingName = "Three-Day Large", RushShippingPrice = 80 }, new RushShipping { RushShippingName = "Three-Day Medium", RushShippingPrice = 70 }, new RushShipping { RushShippingName = "Three-Day Small", RushShippingPrice = 60 }, new RushShipping { RushShippingName = "Five-Day Large", RushShippingPrice = 60 }, new RushShipping { RushShippingName = "Five-Day Medium", RushShippingPrice = 50 }, new RushShipping { RushShippingName = "Five-Day Small", RushShippingPrice = 40 }, new RushShipping { RushShippingName = "Seven-Day Large", RushShippingPrice = 40 }, new RushShipping { RushShippingName = "Seven-Day Medium", RushShippingPrice = 35 }, new RushShipping { RushShippingName = "Seven-Day Small", RushShippingPrice = 30 }, new RushShipping { RushShippingName = "Standard", RushShippingPrice = 0 } }; foreach (RushShipping rS in shippingPrices) { context.RushShipping.Add(rS); } context.SaveChanges(); var surfaceMaterials = new SurfaceMaterial[] { new SurfaceMaterial { SurfaceMaterialName = "Oak", SurfaceMaterialPrice = 200 }, new SurfaceMaterial { SurfaceMaterialName = "Laminate", SurfaceMaterialPrice = 100 }, new SurfaceMaterial { SurfaceMaterialName = "Pine", SurfaceMaterialPrice = 50 }, new SurfaceMaterial { SurfaceMaterialName = "Rosewood", SurfaceMaterialPrice = 300 }, new SurfaceMaterial { SurfaceMaterialName = "Veneer", SurfaceMaterialPrice = 125 } }; foreach (SurfaceMaterial s in surfaceMaterials) { context.SurfaceMaterial.Add(s); } context.SaveChanges(); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService <DbContextOptions <MegaDeskWebContext> >())) { //DeskMaterials if (!context.DeskMaterial.Any()) { context.DeskMaterial.AddRange( new DeskMaterial { DeskMaterialName = "Oak", DeskMaterialPrice = 200, }, new DeskMaterial { DeskMaterialName = "Laminate", DeskMaterialPrice = 100, }, new DeskMaterial { DeskMaterialName = "Pine", DeskMaterialPrice = 50, }, new DeskMaterial { DeskMaterialName = "Rosewood", DeskMaterialPrice = 300, }, new DeskMaterial { DeskMaterialName = "Veneer", DeskMaterialPrice = 125, } ); } //RushShipping if (!context.RushShipping.Any()) { context.RushShipping.AddRange( new RushShipping { RushName = "3 Day Min", RushPrice = 60 }, new RushShipping { RushName = "3 Day Med", RushPrice = 70 }, new RushShipping { RushName = "3 Day Max", RushPrice = 80 }, new RushShipping { RushName = "5 Day Min", RushPrice = 40 }, new RushShipping { RushName = "5 Day Med", RushPrice = 50 }, new RushShipping { RushName = "5 Day Max", RushPrice = 60 }, new RushShipping { RushName = "7 Day Min", RushPrice = 30 }, new RushShipping { RushName = "7 Day Med", RushPrice = 35 }, new RushShipping { RushName = "7 Day Max", RushPrice = 40 } ); } //DeskQuotes & Desks Here if (!context.DeskQuote.Any()) { } context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService < DbContextOptions <MegaDeskWebContext> >())) { // Look for any desktop surface materials if (context.DesktopSurfaceMaterial.Any()) { return; // Table has been seeded } else { context.DesktopSurfaceMaterial.AddRange( new DesktopSurfaceMaterial { Name = "Pine", Cost = 50 }, new DesktopSurfaceMaterial { Name = "Laminate", Cost = 100 }, new DesktopSurfaceMaterial { Name = "Veneer", Cost = 125 }, new DesktopSurfaceMaterial { Name = "Oak", Cost = 200 }, new DesktopSurfaceMaterial { Name = "Rosewood", Cost = 300 } ); } // Look for any rush order options if (context.RushOrderOption.Any()) { return; // Table has been seeded } else { context.RushOrderOption.AddRange( new RushOrderOption { Option = "14 day", CostSmall = 0, CostMedium = 0, CostLarge = 0 }, new RushOrderOption { Option = "7 day", CostSmall = 30, CostMedium = 35, CostLarge = 40 }, new RushOrderOption { Option = "5 day", CostSmall = 40, CostMedium = 50, CostLarge = 60 }, new RushOrderOption { Option = "3 day", CostSmall = 60, CostMedium = 70, CostLarge = 80 } ); } context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService < DbContextOptions <MegaDeskWebContext> >())) { //look for any data if (context.Quote.Any()) { return; //DB seeded no quotes added } context.Quote.AddRange( new Quote { quoteDate = DateTime.Parse("2020-02-02"), firstname = "Hans", lastname = "Solo", width = 48, depth = 28, drawers = 5, surfaceMaterial = "Oak", rushDelivery = 0, total = 1802 }, new Quote { quoteDate = DateTime.Parse("2020-01-27"), firstname = "Luke", lastname = "Skywalker", width = 36, depth = 30, drawers = 2, surfaceMaterial = "Pine", rushDelivery = 3, total = 1500 }, new Quote { quoteDate = DateTime.Parse("2020-02-29"), firstname = "Leia", lastname = "Organa", width = 24, depth = 18, drawers = 1, surfaceMaterial = "Rosewood", rushDelivery = 5, total = 1022 }, new Quote { quoteDate = DateTime.Parse("2020-01-01"), firstname = "Darth", lastname = "Vader", width = 96, depth = 48, drawers = 7, surfaceMaterial = "Oak", rushDelivery = 7, total = 5254 }, new Quote { quoteDate = DateTime.Parse("2019-12-11"), firstname = "Minch", lastname = "Yoda", width = 24, depth = 12, drawers = 0, surfaceMaterial = "Veneer", rushDelivery = 0, total = 613 } ); context.SaveChanges(); //quotes added } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskWebContext( serviceProvider.GetRequiredService < DbContextOptions <MegaDeskWebContext> >())) { /* * // Look for any movies. * if (context.Quote.Any()) * { * return; // DB has been seeded * } * * context.Quote.AddRange( * new Quote * { * CustomerName = "Breena", * QuoteDate = DateTime.Parse("2019-1-1"), * DeskPrice = 344 * } * ); * // Look for any movies. * if (context.Desk.Any()) * { * return; // DB has been seeded * } * * context.Desk.AddRange( * new Desk * { * Width = 34, * Depth = 45, * NumDrawers = 4, * } * ); * // Look for any movies. */ // Look for any surface material. if (context.SurfaceMaterial.Any()) { return; // DB has been seeded } context.SurfaceMaterial.AddRange( new SurfaceMaterial { SurfaceMaterialName = "Oak", SurfaceMaterialPrice = 200 }, new SurfaceMaterial { SurfaceMaterialName = "Laminate", SurfaceMaterialPrice = 100 }, new SurfaceMaterial { SurfaceMaterialName = "Pine", SurfaceMaterialPrice = 50 }, new SurfaceMaterial { SurfaceMaterialName = "RoseWood", SurfaceMaterialPrice = 300 }, new SurfaceMaterial { SurfaceMaterialName = "Veneer", SurfaceMaterialPrice = 125 } ); // Look for any delivery. if (context.Delivery.Any()) { return; // DB has been seeded } context.Delivery.AddRange( new Delivery { DeliveryName = "3 Day", LessThan1000 = 60, From1000To2000 = 70, GreaterThan2000 = 80 }, new Delivery { DeliveryName = "5 Day", LessThan1000 = 40, From1000To2000 = 50, GreaterThan2000 = 60 }, new Delivery { DeliveryName = "7 Day", LessThan1000 = 30, From1000To2000 = 35, GreaterThan2000 = 40 } ); context.SaveChanges(); } }