コード例 #1
0
ファイル: DeskQuote.cs プロジェクト: Flint64/MegaDeskRazor
        public decimal GetQuote(MegaDeskRazorContext context)
        {
            //Desk base price
            Price = 200;

            this.Desk.SurfaceArea = (this.Desk.Width * this.Desk.Depth);

            //If surface area is over 1000, charge for every inch over 1000
            if (this.Desk.SurfaceArea > 1000)
            {
                Price += (this.Desk.SurfaceArea - 1000);
            }

            /*Pull from the database*/
            Price += context.SurfaceMaterial.Where(d => d.SurfaceMaterialId == this.Desk.SurfaceMaterialId).FirstOrDefault().Price;

            Price += context.NumDrawers.Where(d => d.NumDrawersId == this.Desk.NumDrawersId).FirstOrDefault().Price;

            if (this.Desk.SurfaceArea < 1000)
            {
                Price += context.RushOption.Where(d => d.RushOptionId == this.RushOptionId).FirstOrDefault().PriceUnder1000;
            }
            else if (this.Desk.SurfaceArea >= 1000 && this.Desk.SurfaceArea < 2000)
            {
                Price += context.RushOption.Where(d => d.RushOptionId == this.RushOptionId).FirstOrDefault().PriceBetween1000And2000;
            }
            else if (this.Desk.SurfaceArea > 2000)
            {
                Price += context.RushOption.Where(d => d.RushOptionId == this.RushOptionId).FirstOrDefault().PriceOver2000;
            }
            return(Price);
        }
コード例 #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MegaDeskRazorContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MegaDeskRazorContext> >()))
            {
                // Look for any Quotes.
                if (context.Desk.Any())
                {
                    return;   // DB has been seeded
                }

                context.Desk.AddRange(
                    new Desk
                {
                    customerName    = "Bill Gates",
                    width           = 30.00,
                    depth           = 30.00,
                    numberOfDrawers = 2,
                    price           = 1025.00M,
                    surfaceMaterial = "Rosewood",
                    rushOrder       = "7",
                    DateAdded       = DateTime.Parse("2021-02-25")
                },

                    new Desk
                {
                    customerName    = "Test 1",
                    width           = 30.00,
                    depth           = 30.00,
                    numberOfDrawers = 2,
                    price           = 1025.00M,
                    surfaceMaterial = "Rosewood",
                    rushOrder       = "7",
                    DateAdded       = DateTime.Parse("2021-02-01")
                },

                    new Desk
                {
                    customerName    = "Mic",
                    width           = 30.00,
                    depth           = 30.00,
                    numberOfDrawers = 2,
                    price           = 1025.00M,
                    surfaceMaterial = "Rosewood",
                    rushOrder       = "7",
                    DateAdded       = DateTime.Parse("2021-02-10")
                }

                    );
                context.SaveChanges();
            }
        }
コード例 #3
0
ファイル: DeskQuote.cs プロジェクト: mdoda/MeagaDeskRazor
        public decimal GetQuotePrice(MegaDeskRazorContext context)
        {
            var     surfaceArea = this.Desk.Depth * this.Desk.Width;
            decimal quotePrice  = BASE_PRICE;

            decimal surfacePrice = 0.00M;

            if (surfaceArea > 1000)
            {
                surfacePrice = surfaceArea * SURFACE_AREA_COST;
            }

            decimal drawerPrice = this.Desk.NumberOfDrawers * DRAWER_COST;

            decimal surfaceMaterialPrice = 0.00M;

            var surfaceMaterialPrices = context.DesktopMaterial.
                                        Where(d => d.DesktopMaterialId == this.Desk.DesktopMaterialId).FirstOrDefault();

            surfaceMaterialPrice = surfaceMaterialPrices.MaterialPrice;

            //quotePrice = context.Desk.DesktopMaterial.MaterialPrice ;

            var shippingPrice = 0.00M;

            var shippingPrices = context.Delivery.Where(sh => sh.DeliveryId == this.Delivery.DeliveryId).FirstOrDefault();


            if (surfaceArea < 1000)
            {
                shippingPrice = shippingPrices.PriceLessThan1000;
            }
            else if (surfaceArea <= 2000)
            {
                shippingPrice = shippingPrices.PriceBetween1000And2000;
            }
            else
            {
                shippingPrice = shippingPrices.PriceOver2000;
            }

            quotePrice = quotePrice + surfacePrice + drawerPrice + surfaceMaterialPrice + shippingPrice;


            return(quotePrice);
        }
コード例 #4
0
ファイル: DeskQuote.cs プロジェクト: MAAvenger/MegaDeskRazor
        public decimal GetQuotePrice(MegaDeskRazorContext context)
        {
            decimal Base = 200;

            //get material price from db

            decimal materialPrice = 0;

            var materialPrices = context.SurfaceMaterial
                                 .Where(d => d.SurfaceMaterialId == this.Desk.SurfaceMaterialId).FirstOrDefault();

            materialPrice = materialPrices.SurfaceCost;

            //get shipping price from db
            decimal shippingCost = 0;

            var shippingCosts = context.Shipping
                                .Where(s => s.ShippingId == this.ShippingId).FirstOrDefault();

            decimal area = this.Desk.Width * this.Desk.Depth;

            if (area < 1000)
            {
                shippingCost = shippingCosts.ShippingUnder1000;
            }
            else if (area < 2000)
            {
                shippingCost = shippingCosts.ShippingBtwn10002000;
            }
            else if (area > 2000)
            {
                shippingCost = shippingCosts.ShippingOver2000;
            }
            else
            {
                shippingCost = 0;
            }
            this.QuotePrice = Base + GetAreaPrice() + GetDrawerPrice() + materialPrice + (decimal)shippingCost;

            return(this.QuotePrice);
        }