Example #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MegaDeskContext> >()))
            {
                // Look for any Quotes.
                if (context.Quote.Any())
                {
                    return;   // DB has been seeded
                }

                context.Quote.AddRange(
                    new Desk
                {
                    name       = "John Doe",
                    width      = 30.00,
                    depth      = 30.00,
                    numDrawers = 2,
                    price      = 1025.00M,
                    surfaceMat = "Rosewood",
                    rushOrd    = "7 Days",
                    DateAdded  = DateTime.Parse("2018-11-5")
                }



                    );
                context.SaveChanges();
            }
        }
Example #2
0
        public decimal GetDeskQuote(MegaDeskContext context)
        {
            decimal baseCost = 200;
            // Surface Area Cost
            decimal surfaceArea     = this.Desk.Width * this.Desk.Depth;
            decimal surfaceAreaCost = 0;

            if (surfaceArea > 1000)
            {
                surfaceAreaCost = surfaceArea - 1000;
            }

            // ShippingCost
            ShippingType = context.Shipping.Where(s => s.ShippingId == this.ShippingTypeId).FirstOrDefault();


            decimal shippingCost = 0.00M;

            if (surfaceArea < 1000)
            {
                shippingCost = ShippingType.PriceUnder1000;
            }
            else if (surfaceArea >= 10000 && surfaceArea <= 2000)
            {
                shippingCost = ShippingType.PriceBetween1000And2000;
            }
            else
            {
                shippingCost = ShippingType.PriceOver2000;
            }


            // Drawers Cost
            decimal drawersCost = this.Desk.NumberOfDrawers * 50;

            // Material Cost
            DesktopMaterial material = context.DesktopMaterial.Where(m => m.DesktopMaterialId == this.Desk.DesktopMaterialId).FirstOrDefault();

            decimal materialCost = material.DesktopMaterialPrice;

            decimal totalCost = baseCost + surfaceAreaCost + shippingCost + drawersCost + materialCost;

            return(totalCost);
        }
Example #3
0
 public EditModel(MegaDesk.Models.MegaDeskContext context)
 {
     _context = context;
 }
Example #4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MegaDeskContext> >()))
            {
                // Look for any movies.
                if (context.DeskQuote.Any())
                {
                    return;   // DB has been seeded
                }

                context.DeskQuote.AddRange(
                    new DeskQuote
                {
                    CustomerName = "Nick Newman",
                    Date         = DateTime.Parse("1998-2-18"),
                    Width        = 35.23M,
                    Deep         = 44.20M,
                    Drawers      = 3,
                    Material     = "Oak",
                    Shipping     = 7,
                    Cost         = 380.00M,
                    Area         = 757.17M
                },

                    new DeskQuote
                {
                    CustomerName = "Carson Clay",
                    Date         = DateTime.Parse("2005-6-30"),
                    Width        = 45.30M,
                    Deep         = 25.60M,
                    Drawers      = 4,
                    Material     = "Pine",
                    Shipping     = 5,
                    Cost         = 290.00M,
                    Area         = 359.68M
                },

                    new DeskQuote
                {
                    CustomerName = "Mario Garcia",
                    Date         = DateTime.Parse("2020-8-10"),
                    Width        = 25.87M,
                    Deep         = 15.37M,
                    Drawers      = 6,
                    Material     = "Rosewood",
                    Shipping     = 3,
                    Cost         = 660.00M,
                    Area         = 200.00M
                },

                    new DeskQuote
                {
                    CustomerName = "Juan Rivera",
                    Date         = DateTime.Parse("2015-2-22"),
                    Width        = 28.550M,
                    Deep         = 40.11M,
                    Drawers      = 7,
                    Material     = "Veneer",
                    Shipping     = 14,
                    Cost         = 475.00M,
                    Area         = 345.14M
                },

                    new DeskQuote
                {
                    CustomerName = "George Anderson",
                    Date         = DateTime.Parse("2018-12-31"),
                    Width        = 90.210M,
                    Deep         = 33.87M,
                    Drawers      = 2,
                    Material     = "Oak",
                    Shipping     = 5,
                    Cost         = 340.00M,
                    Area         = 2255.41M
                }



                    );
                context.SaveChanges();
            }
        }
Example #5
0
 public DeleteModel(MegaDesk.Models.MegaDeskContext context)
 {
     _context = context;
 }
Example #6
0
 public DetailsModel(MegaDesk.Models.MegaDeskContext context)
 {
     _context = context;
 }
 public CreateModel(MegaDesk.Models.MegaDeskContext context)
 {
     _context = context;
 }
Example #8
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MegaDeskContext> >()))
            {
                //Look for any surface materials and add if missing.
                if (!context.SurfaceMaterial.Any())
                {
                    context.SurfaceMaterial.AddRange(
                        new SurfaceMaterial
                    {
                        Description = "Pine",
                        Cost        = 50,
                        ImageFile   = "pine.jpg"
                    },
                        new SurfaceMaterial
                    {
                        Description = "Laminate",
                        Cost        = 100,
                        ImageFile   = "laminate.jpg"
                    },
                        new SurfaceMaterial
                    {
                        Description = "Veneer",
                        Cost        = 125,
                        ImageFile   = "veneer.jpg"
                    },
                        new SurfaceMaterial
                    {
                        Description = "Oak",
                        Cost        = 200,
                        ImageFile   = "oak.jpg"
                    },
                        new SurfaceMaterial
                    {
                        Description = "Rosewood",
                        Cost        = 300,
                        ImageFile   = "rosewood.jpg"
                    }

                        );
                    context.SaveChanges();
                }

                //Look for any surface materials and add if missing.
                if (!context.RushType.Any())
                {
                    context.RushType.AddRange(
                        new RushType
                    {
                        Description = "Standard Shipping",
                        Tier1Cost   = 0,
                        Tier2Cost   = 0,
                        Tier3Cost   = 0
                    },
                        new RushType
                    {
                        Description = "7-Day Shipping",
                        Tier1Cost   = 30,
                        Tier2Cost   = 35,
                        Tier3Cost   = 40
                    },
                        new RushType
                    {
                        Description = "5-Day Shipping",
                        Tier1Cost   = 40,
                        Tier2Cost   = 50,
                        Tier3Cost   = 60
                    },
                        new RushType
                    {
                        Description = "3-Day Shipping",
                        Tier1Cost   = 60,
                        Tier2Cost   = 70,
                        Tier3Cost   = 80
                    }
                        );

                    if (!context.DeskQuote.Any())
                    {
                        context.DeskQuote.AddRange(
                            new DeskQuote
                        {
                            CustomerName = "John Smith",
                            Desk         = new Desk
                            {
                                Width             = 24,
                                Depth             = 13,
                                Drawers           = 0,
                                SurfaceMaterialId = 1
                            },
                            RushId             = 4,
                            PricePerSquareInch = 1,
                            PricePerDrawer     = 50,
                            BasePrice          = 200,
                            SurfacePriceFloor  = 1000,
                            MaterialCost       = 50,
                            ShippingCost       = 0,
                            CreatedDate        = DateTime.Parse("2020-02-27 00:00:00")
                        },
                            new DeskQuote
                        {
                            CustomerName = "Sam Smith",
                            Desk         = new Desk
                            {
                                Width             = 33,
                                Depth             = 33,
                                Drawers           = 3,
                                SurfaceMaterialId = 3
                            },
                            RushId             = 2,
                            PricePerSquareInch = 1,
                            PricePerDrawer     = 50,
                            BasePrice          = 200,
                            SurfacePriceFloor  = 1000,
                            MaterialCost       = 100,
                            ShippingCost       = 50,
                            CreatedDate        = DateTime.Parse("2020-02-28 00:00:00")
                        }
                            ,
                            new DeskQuote
                        {
                            CustomerName = "Sally Field",
                            Desk         = new Desk
                            {
                                Width             = 44,
                                Depth             = 44,
                                Drawers           = 7,
                                SurfaceMaterialId = 1
                            },
                            RushId             = 1,
                            PricePerSquareInch = 1,
                            PricePerDrawer     = 50,
                            BasePrice          = 200,
                            SurfacePriceFloor  = 1000,
                            MaterialCost       = 50,
                            ShippingCost       = 70,
                            CreatedDate        = DateTime.Parse("2020-02-29 00:00:00")
                        });
                    }
                    context.SaveChanges();
                }
            }
        }
Example #9
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MegaDeskContext> >()))
            {
                // If the database already has 1 or more records, skipping seeding the DB
                if (context.Order.Any())
                {
                    return;
                }

                // If it is empty, then lets add in some orders that we can play with
                context.Order.AddRange(
                    new Order
                {
                    FirstName       = "Floor",
                    LastName        = "Jansen",
                    Width           = 35,
                    Depth           = 48,
                    Drawers         = 5,
                    SurfaceMaterial = "Oak",
                    RushOrder       = 3,
                    QuoteTotal      = 1400,
                    DateAdded       = DateTime.Parse("2020-1-05")
                },

                    new Order
                {
                    FirstName       = "Gavin",
                    LastName        = "Rossdale",
                    Width           = 40,
                    Depth           = 25,
                    Drawers         = 1,
                    SurfaceMaterial = "Veneer",
                    RushOrder       = 5,
                    QuoteTotal      = 435,
                    DateAdded       = DateTime.Parse("2020-1-07")
                },

                    new Order
                {
                    FirstName       = "Billy",
                    LastName        = "Corgan",
                    Width           = 25,
                    Depth           = 13,
                    Drawers         = 7,
                    SurfaceMaterial = "Pine",
                    RushOrder       = 14,
                    QuoteTotal      = 600,
                    DateAdded       = DateTime.Parse("2020-1-10")
                },

                    new Order
                {
                    FirstName       = "James",
                    LastName        = "Hetfield",
                    Width           = 30,
                    Depth           = 40,
                    Drawers         = 7,
                    SurfaceMaterial = "Laminate",
                    RushOrder       = 3,
                    QuoteTotal      = 920,
                    DateAdded       = DateTime.Parse("2020-1-15")
                },

                    new Order
                {
                    FirstName       = "Robert",
                    LastName        = "Plant",
                    Width           = 80,
                    Depth           = 35,
                    Drawers         = 2,
                    SurfaceMaterial = "Rosewood",
                    RushOrder       = 5,
                    QuoteTotal      = 2460,
                    DateAdded       = DateTime.Parse("2020-1-25")
                },

                    new Order
                {
                    FirstName       = "Gwen",
                    LastName        = "Stefani",
                    Width           = 35,
                    Depth           = 41,
                    Drawers         = 5,
                    SurfaceMaterial = "Veneer",
                    RushOrder       = 3,
                    QuoteTotal      = 1080,
                    DateAdded       = DateTime.Parse("2020-2-05")
                }


                    );

                context.SaveChanges();
            }
        }
Example #10
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MegaDeskContext> >()))
            {
                // Look for any movies.
                if (context.DesktopMaterial.Any())
                {
                    return;   // DB has been seeded
                }

                context.DesktopMaterial.AddRange(
                    new DesktopMaterial
                {
                    MaterialName = "Oak",
                    Cost         = 200
                },
                    new DesktopMaterial
                {
                    MaterialName = "Laminate",
                    Cost         = 100
                },
                    new DesktopMaterial
                {
                    MaterialName = "Pine",
                    Cost         = 50
                },
                    new DesktopMaterial
                {
                    MaterialName = "Veneer",
                    Cost         = 125
                },
                    new DesktopMaterial
                {
                    MaterialName = "Oak",
                    Cost         = 200
                }
                    );

                context.DeliveryOption.AddRange(
                    new DeliveryOption
                {
                    DeliveryName = "3 Day"
                },
                    new DeliveryOption
                {
                    DeliveryName = "5 Day"
                },
                    new DeliveryOption
                {
                    DeliveryName = "7 Day"
                },
                    new DeliveryOption
                {
                    DeliveryName = "14 Day (Normal Shipping)"
                }
                    );

                context.SaveChanges();
            }
        }
Example #11
0
 public IndexModel(MegaDesk.Models.MegaDeskContext context)
 {
     _context = context;
 }