コード例 #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            //Less than 1000 inches

            if (Quote.Width * Quote.Depth < Quote.BASESIZE)
            {
                Quote.TotalAmount += Quote.BASEPRICE;

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += Quote.RUSHDAYS3;
                    break;

                case 5:
                    Quote.TotalAmount += Quote.RUSHDAYS5;
                    break;

                case 7:
                    Quote.TotalAmount += Quote.RUSHDAYS7;
                    break;
                }
            }

            //Between 1000 and 2000 inches

            else if (Quote.Width * Quote.Depth < Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += 70;
                    break;

                case 5:
                    Quote.TotalAmount += 50;
                    break;

                case 7:
                    Quote.TotalAmount += 35;
                    break;
                }
            }


            //Greater than 2000

            else if (Quote.Width * Quote.Depth >= Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += 80;
                    break;

                case 5:
                    Quote.TotalAmount += 60;
                    break;

                case 7:
                    Quote.TotalAmount += 40;
                    break;
                }
            }

            //Material Price
            switch (Quote.Material)
            {
            case "Oak":
                Quote.TotalAmount += Quote.OAKPRICE;
                break;

            case "Laminate":
                Quote.TotalAmount += Quote.LAMINATEPRICE;
                break;

            case "Pine":
                Quote.TotalAmount += Quote.PINEPRICE;
                break;

            case "Rosewood":
                Quote.TotalAmount += Quote.ROSEPRICE;
                break;

            case "Veneer":
                Quote.TotalAmount += Quote.VENEERPRICE;
                break;
            }

            //Validation for Drawers
            switch (Quote.NumOfDrawers)
            {
            case 0:
                Quote.TotalAmount += 0;
                break;

            case 1:
                Quote.TotalAmount += 50;
                break;

            case 2:
                Quote.TotalAmount += 100;
                break;

            case 3:
                Quote.TotalAmount += 150;
                break;

            case 4:
                Quote.TotalAmount += 200;
                break;

            case 5:
                Quote.TotalAmount += 250;
                break;

            case 6:
                Quote.TotalAmount += 300;
                break;

            case 7:
                Quote.TotalAmount += 350;
                break;
            }

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            //Less than 1000 inches

            if (Quote.Width * Quote.Depth < Quote.BASESIZE)
            {
                Quote.TotalAmount += Quote.BASEPRICE;

                switch (Quote.Material)
                {
                case "Oak":
                    Quote.TotalAmount += Quote.OAKPRICE;
                    break;

                case "Laminate":
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                    break;

                case "Pine":
                    Quote.TotalAmount += Quote.PINEPRICE;
                    break;

                case "Rosewood":
                    Quote.TotalAmount += Quote.ROSEPRICE;
                    break;

                case "Veneer":
                    Quote.TotalAmount += Quote.VENEERPRICE;
                    break;
                }

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += Quote.RUSHDAYS3;
                    break;

                case 5:
                    Quote.TotalAmount += Quote.RUSHDAYS5;
                    break;

                case 7:
                    Quote.TotalAmount += Quote.RUSHDAYS7;
                    break;
                }
            }

            //Between 1000 and 2000 inches

            else if (Quote.Width * Quote.Depth < Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;
                switch (Quote.Material)
                {
                case "Oak":
                    Quote.TotalAmount += Quote.OAKPRICE;
                    break;

                case "Laminate":
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                    break;

                case "Pine":
                    Quote.TotalAmount += Quote.PINEPRICE;
                    break;

                case "Rosewood":
                    Quote.TotalAmount += Quote.ROSEPRICE;
                    break;

                case "Veneer":
                    Quote.TotalAmount += Quote.VENEERPRICE;
                    break;
                }

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += 70;
                    break;

                case 5:
                    Quote.TotalAmount += 50;
                    break;

                case 7:
                    Quote.TotalAmount += 35;
                    break;
                }
            }


            //Greater than 2000

            else if (Quote.Width * Quote.Depth >= Quote.MIDDLESIZE)
            {
                Quote.TotalAmount += Quote.Width * Quote.Depth;
                switch (Quote.Material)
                {
                case "Oak":
                    Quote.TotalAmount += Quote.OAKPRICE;
                    break;

                case "Laminate":
                    Quote.TotalAmount += Quote.LAMINATEPRICE;
                    break;

                case "Pine":
                    Quote.TotalAmount += Quote.PINEPRICE;
                    break;

                case "Rosewood":
                    Quote.TotalAmount += Quote.ROSEPRICE;
                    break;

                case "Veneer":
                    Quote.TotalAmount += Quote.VENEERPRICE;
                    break;
                }

                //Validation for RushOrder
                switch (Quote.RushOrder)
                {
                case 3:
                    Quote.TotalAmount += 80;
                    break;

                case 5:
                    Quote.TotalAmount += 60;
                    break;

                case 7:
                    Quote.TotalAmount += 40;
                    break;
                }
            }

            //Validation for Drawers
            switch (Quote.NumOfDrawers)
            {
            case 0:
                Quote.TotalAmount += 0;
                break;

            case 1:
                Quote.TotalAmount += 50;
                break;

            case 2:
                Quote.TotalAmount += 100;
                break;

            case 3:
                Quote.TotalAmount += 150;
                break;

            case 4:
                Quote.TotalAmount += 200;
                break;

            case 5:
                Quote.TotalAmount += 250;
                break;

            case 6:
                Quote.TotalAmount += 300;
                break;

            case 7:
                Quote.TotalAmount += 350;
                break;
            }

            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"));
        }