public void UpdateShippingName(MegaDeskContext context, int rushId) { var shippingMethod = context.RushType .Single(r => r.Id == rushId); ShippingName = shippingMethod.Description; }
public void UpdateMaterialCost(MegaDeskContext context, int materialId) { var material = context.SurfaceMaterial .Single(m => m.Id == materialId); MaterialCost = material.Cost; }
public void UpdateMaterialName(MegaDeskContext context, int materialId) { var material = context.SurfaceMaterial .Single(m => m.Id == materialId); MaterialName = material.Description; }
public EditModel(MegaDeskContext context, IConfiguration configuration) { _context = context; _configuration = configuration; RushTypeList = context.RushType.Select(a => new SelectListItem { Value = a.Id.ToString(), Text = a.Description }).ToList(); SurfaceMaterialList = context.SurfaceMaterial.Select(a => new SelectListItem { Value = a.Id.ToString(), Text = a.Description }).ToList(); }
public void UpdateShippingCost(MegaDeskContext context, IConfiguration configuration, int rushId, int surfaceArea) { var shippingMethod = context.RushType .Single(r => r.Id == rushId); int tier2Floor = int.Parse(configuration["Pricing:Tier2Floor"]); int tier3Floor = int.Parse(configuration["Pricing:Tier3Floor"]); if (surfaceArea < tier2Floor) { ShippingCost = shippingMethod.Tier1Cost; } else if (surfaceArea < tier3Floor) { ShippingCost = shippingMethod.Tier2Cost; } else { ShippingCost = shippingMethod.Tier3Cost; } }
public EditModel(MegaDeskContext context) { _context = context; }
public DetailsModel(MegaDeskContext context) { _context = context; }
public DeleteModel(MegaDeskContext context) { _context = context; }
public IndexModel(MegaDeskContext context) { _context = context; }
public CreateModel(MegaDeskContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MegaDeskContext( serviceProvider.GetRequiredService < DbContextOptions <MegaDeskContext> >())) { // Look if Surface Materials exist yet. if (context.SurfaceMaterials == null || !context.SurfaceMaterials.Any()) { context.SurfaceMaterials.AddRange( new SurfaceMaterial { Name = "Pine", Price = 50.00M }, new SurfaceMaterial { Name = "Laminate", Price = 100.00M }, new SurfaceMaterial { Name = "Veneer", Price = 125.00M }, new SurfaceMaterial { Name = "Oak", Price = 200.00M }, new SurfaceMaterial { Name = "Rosewood", Price = 300.00M } ); context.SaveChanges(); } if (context.RushOrderTypes == null || !context.RushOrderTypes.Any()) { context.RushOrderTypes.AddRange( new RushOrder { RushOrderName = "7-day", TierOnePrice = 60.00M, TierTwoPrice = 40.00M, TierThreePrice = 30.00M }, new RushOrder { RushOrderName = "5-day", TierOnePrice = 70.00M, TierTwoPrice = 50.00M, TierThreePrice = 35.00M }, new RushOrder { RushOrderName = "3-day", TierOnePrice = 80.00M, TierTwoPrice = 60.00M, TierThreePrice = 40.00M } ); context.SaveChanges(); } } }