Exemple #1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Calculate the Desk Price
            DeskQuote.DeskPrice = Program.CalcTotalPrice(DeskQuote.Width, DeskQuote.Depth, DeskQuote.Drawers, DeskQuote.RushOrderDays, DeskQuote.DeskMaterial);

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeskQuoteExists(DeskQuote.DeskQuoteID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #2
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"));
        }
Exemple #3
0
        //[Bind("CustomerName, Desk, QuotePrice, Shipping")] DeskQuote deskQuote
        //
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0)
                             .Select(x => new { x.Key, x.Value.Errors })
                             .ToArray();
                //return Page();
            }


            DeskQuote.Desk   = Desk;
            DeskQuote.DeskId = Desk.DeskId;


            DeskQuote.QuotePrice = DeskQuote.getQuotePrice(_context);

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



            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeskQuoteExists(DeskQuote.DeskQuoteId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(RedirectToPage("./Index"));
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (Quote.Width * Quote.Depth < Quote.BASESIZE)
            {
                Quote.TotalAmount += Quote.BASEPRICE;

                if (Quote.Material == "Oak")
                {
                    Quote.TotalAmount += Quote.OAKPRICE;
                }
                if (Quote.Material == "Laminate")
                {
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                }
                if (Quote.Material == "Pine")
                {
                    Quote.TotalAmount += Quote.PINEPRICE;
                }
                if (Quote.Material == "Rosewood")
                {
                    Quote.TotalAmount += Quote.ROSEPRICE;
                }
                if (Quote.Material == "Veneer")
                {
                    Quote.TotalAmount += Quote.VENEERPRICE;
                }

                if (Quote.RushOrder == 3)
                {
                    Quote.TotalAmount += Quote.RUSHDAYS3;
                }

                if (Quote.RushOrder == 5)
                {
                    Quote.TotalAmount += Quote.RUSHDAYS5;
                }
                if (Quote.RushOrder == 7)
                {
                    Quote.TotalAmount += Quote.RUSHDAYS7;
                }
                if (Quote.NumOfDrawers == 0)
                {
                    Quote.TotalAmount += 0;
                }

                if (Quote.NumOfDrawers == 1)
                {
                    Quote.TotalAmount += 50;
                }
                if (Quote.NumOfDrawers == 2)
                {
                    Quote.TotalAmount += 100;
                }
                if (Quote.NumOfDrawers == 3)
                {
                    Quote.TotalAmount += 150;
                }
                if (Quote.NumOfDrawers == 4)
                {
                    Quote.TotalAmount += 200;
                }
                if (Quote.NumOfDrawers == 5)
                {
                    Quote.TotalAmount += 250;
                }
                if (Quote.NumOfDrawers == 6)
                {
                    Quote.TotalAmount += 300;
                }
                if (Quote.NumOfDrawers == 7)
                {
                    Quote.TotalAmount += 350;
                }
            }


            //between 1000 and 2000 inches

            else if (Quote.Width * Quote.Depth < Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;
                if (Quote.Material == "Oak")
                {
                    Quote.TotalAmount += Quote.OAKPRICE;
                }
                if (Quote.Material == "Laminate")
                {
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                }
                if (Quote.Material == "Pine")
                {
                    Quote.TotalAmount += Quote.PINEPRICE;
                }
                if (Quote.Material == "Rosewood")
                {
                    Quote.TotalAmount += Quote.ROSEPRICE;
                }
                if (Quote.Material == "Veneer")
                {
                    Quote.TotalAmount += Quote.VENEERPRICE;
                }

                if (Quote.RushOrder == 3)
                {
                    Quote.TotalAmount += 70;
                }

                if (Quote.RushOrder == 5)
                {
                    Quote.TotalAmount += 50;
                }
                if (Quote.RushOrder == 7)
                {
                    Quote.TotalAmount += 35;
                }

                if (Quote.NumOfDrawers == 0)
                {
                    Quote.TotalAmount += 0;
                }
                if (Quote.NumOfDrawers == 1)
                {
                    Quote.TotalAmount += 50;
                }
                if (Quote.NumOfDrawers == 2)
                {
                    Quote.TotalAmount += 100;
                }
                if (Quote.NumOfDrawers == 3)
                {
                    Quote.TotalAmount += 150;
                }
                if (Quote.NumOfDrawers == 4)
                {
                    Quote.TotalAmount += 200;
                }
                if (Quote.NumOfDrawers == 5)
                {
                    Quote.TotalAmount += 250;
                }
                if (Quote.NumOfDrawers == 6)
                {
                    Quote.TotalAmount += 300;
                }
                if (Quote.NumOfDrawers == 7)
                {
                    Quote.TotalAmount += 350;
                }
            }


            //Greater than 2000

            else if (Quote.Width * Quote.Depth >= Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;
                if (Quote.Material == "Oak")
                {
                    Quote.TotalAmount += Quote.OAKPRICE;
                }
                if (Quote.Material == "Laminate")
                {
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                }
                if (Quote.Material == "Pine")
                {
                    Quote.TotalAmount += Quote.PINEPRICE;
                }
                if (Quote.Material == "Rosewood")
                {
                    Quote.TotalAmount += Quote.ROSEPRICE;
                }
                if (Quote.Material == "Veneer")
                {
                    Quote.TotalAmount += Quote.VENEERPRICE;
                }

                if (Quote.RushOrder == 3)
                {
                    Quote.TotalAmount += 80;
                }

                if (Quote.RushOrder == 5)
                {
                    Quote.TotalAmount += 60;
                }
                if (Quote.RushOrder == 7)
                {
                    Quote.TotalAmount += 40;
                }
                if (Quote.NumOfDrawers == 0)
                {
                    Quote.TotalAmount += 0;
                }
                if (Quote.NumOfDrawers == 1)
                {
                    Quote.TotalAmount += 50;
                }
                if (Quote.NumOfDrawers == 2)
                {
                    Quote.TotalAmount += 100;
                }
                if (Quote.NumOfDrawers == 3)
                {
                    Quote.TotalAmount += 150;
                }
                if (Quote.NumOfDrawers == 4)
                {
                    Quote.TotalAmount += 200;
                }
                if (Quote.NumOfDrawers == 5)
                {
                    Quote.TotalAmount += 250;
                }
                if (Quote.NumOfDrawers == 6)
                {
                    Quote.TotalAmount += 300;
                }
                if (Quote.NumOfDrawers == 7)
                {
                    Quote.TotalAmount += 350;
                }
            }


            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuoteExists(Quote.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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