Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Desk).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeskExists(Desk.DeskID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Material.Add(Material);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Desk = await _context.Desk.FindAsync(id);

            if (Desk != null)
            {
                _context.Desk.Remove(Desk);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Material = await _context.Material.FindAsync(id);

            if (Material != null)
            {
                _context.Material.Remove(Material);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////
            //
            //    START STAPLES AND GLUE CODE BLOCK
            //
            /////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////

            //
            // Convery Material ID to price
            //
            decimal materialPrice = NewQuote.Desk.MaterialID;

            switch (materialPrice)
            {
            case 1:
                materialPrice = 200;
                break;

            case 2:
                materialPrice = 100;
                break;

            case 3:
                materialPrice = 50;
                break;

            case 4:
                materialPrice = 125; break;

            case 5:
                materialPrice = 200; break;

            default:
                materialPrice = 200; break;
            }
            //
            // Convert DeliveryID to DeliveryCost
            //
            String  deliveryType = NewQuote.Delivery.RushOrderDay;
            decimal deliveryCost = 0;

            switch (deliveryType)
            {
            case "3 Day":
                deliveryCost = 3;
                break;

            case "5 Day":
                deliveryCost = 5;
                break;

            case "7 Day":
                deliveryCost = 7;
                break;

            default:
                deliveryCost = 14; break;
            }


            NewQuote.QuoteDate = DateTime.Now;
            decimal Area = NewQuote.Desk.surfaceArea();

            NewQuote.ShippingCost = calcShipPrice(deliveryCost, Area);
            NewQuote.DeskPrice    = calcPrice(materialPrice, Area, NewQuote.ShippingCost, NewQuote.Desk.NumDrawers * 25);



            decimal calcShipPrice(decimal pvRushDays, decimal pvArea)
            {
                decimal shippingPrice;


                if (pvRushDays == 3)
                {
                    if (pvArea < 1000)
                    {
                        shippingPrice = 60;
                    }
                    else if (pvArea < 2001)
                    {
                        shippingPrice = 70;
                    }
                    else
                    {
                        shippingPrice = 80;
                    }
                }
                else if (pvRushDays == 5)
                {
                    if (pvArea < 1000)
                    {
                        shippingPrice = 40;
                    }
                    else if (pvArea < 2001)
                    {
                        shippingPrice = 50;
                    }
                    else
                    {
                        shippingPrice = 60;
                    }
                }
                else if (pvRushDays == 7)
                {
                    if (pvArea < 1000)
                    {
                        shippingPrice = 30;
                    }
                    else if (pvArea < 2001)
                    {
                        shippingPrice = 35;
                    }
                    else
                    {
                        shippingPrice = 40;
                    }
                }
                else
                {
                    shippingPrice = 0;
                }

                return(shippingPrice);
            }

            decimal calcPrice(decimal pvMaterialCost, decimal pvArea, decimal pvShippingCost, decimal pvDrawers)
            {
                if (pvArea < 1000)
                {
                    return(200 + pvShippingCost + pvMaterialCost + pvDrawers);
                }
                else
                {
                    return(200 + pvShippingCost + pvMaterialCost + pvArea + pvDrawers);
                }
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////
            //
            //    END STAPLES AND GLUE CODE BLOCK
            //
            /////////////////////////////////////////////////////////////////////////////////////////
            /////////////////////////////////////////////////////////////////////////////////////////


            _context.DeskQuote.Add(NewQuote);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }