コード例 #1
0
ファイル: Create.cshtml.cs プロジェクト: ArthurFig1998/CIT365
        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();
            }

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

            DeskQuote.Desk      = Desk;
            DeskQuote.DeskId    = Desk.DeskId;
            DeskQuote.QuoteDate = DateTime.Now;



            DeskQuote.QuotePrice = DeskQuote.getQuotePrice(_context);

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

            return(RedirectToPage("./Index"));
        }
コード例 #2
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"));
        }
コード例 #3
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"));
        }
コード例 #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            int matID = Int32.Parse(Request.Form["materialSelect"].ToString());

            DeskQuote.Desk.Material = (Desktop)(from b in _context.Desktop
                                                where b.ID.Equals(matID)
                                                select b).FirstOrDefault();

            int shipID = Int32.Parse(Request.Form["shipSelect"].ToString());

            DeskQuote.Shipping = (Shipping)(from b in _context.Shipping
                                            where b.ID.Equals(shipID)
                                            select b).FirstOrDefault();

            DeskQuote.calculatePrice();
            _context.DeskQuote.Add(DeskQuote);


            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            return(RedirectToPage("./Index"));
        }
コード例 #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            DeskQuote = Calculations.PopulateQuote(DeskQuote, SelectedShip, localMaterialID, _context);
            _context.DeskQuote.Add(DeskQuote);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #7
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"));
        }
コード例 #8
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());
            }

            // Quote date for creating new quote
            DeskQuote.QuoteDate = DateTime.Now;

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #9
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());
            }
            DeskQuote.setQuoteDate();
            _context.DeskQuote.Add(DeskQuote);
            // Run functions to calculate other required fields
            DeskQuote.calcSurfaceArea();

            DeskQuote.calcRushPricing();
            DeskQuote.getMaterialPrice();
            DeskQuote.calcTotalCost();
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #10
0
ファイル: Edit.cshtml.cs プロジェクト: ArthurFig1998/CIT365
        //[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"));
        }
コード例 #11
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"));
        }
コード例 #12
0
        public async Task <IActionResult> OnPostAsync()
        {
            //less than 1000 inches

            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.Quote.Add(Quote);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Details", new { id = Quote.ID }));
        }