Beispiel #1
0
        public void UpdateShippingName(MegaDeskContext context, int rushId)
        {
            var shippingMethod = context.RushType
                                 .Single(r => r.Id == rushId);

            ShippingName = shippingMethod.Description;
        }
Beispiel #2
0
        public void UpdateMaterialCost(MegaDeskContext context, int materialId)
        {
            var material = context.SurfaceMaterial
                           .Single(m => m.Id == materialId);

            MaterialCost = material.Cost;
        }
Beispiel #3
0
        public void UpdateMaterialName(MegaDeskContext context, int materialId)
        {
            var material = context.SurfaceMaterial
                           .Single(m => m.Id == materialId);

            MaterialName = material.Description;
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        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;
            }
        }
Beispiel #6
0
 public EditModel(MegaDeskContext context)
 {
     _context = context;
 }
 public DetailsModel(MegaDeskContext context)
 {
     _context = context;
 }
 public DeleteModel(MegaDeskContext context)
 {
     _context = context;
 }
 public IndexModel(MegaDeskContext context)
 {
     _context = context;
 }
Beispiel #10
0
 public CreateModel(MegaDeskContext context)
 {
     _context = context;
 }
Beispiel #11
0
        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();
                }
            }
        }