// To protect from overposting attacks, 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.QuoteDate = DateTime.Now;

            // Get the material for calculating the price
            DeskQuote.Desk.DesktopMaterial = _context.DesktopMaterial
                                             .FirstOrDefault(d => d.DesktopMaterialId == DeskQuote.Desk.DesktopMaterialId);
            // Get the delivery option for calculating the price
            DeskQuote.DeliveryOption = _context.DeliveryOption
                                       .FirstOrDefault(d => d.DeliveryOptionId == DeskQuote.DeliveryOptionId);

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

            DeskQuote.DeskId     = DeskQuote.Desk.DeskId;
            DeskQuote.QuotePrice = DeskQuote.CalculatePriceQuote();

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

            return(RedirectToPage("./Index"));
        }
Exemple #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());
            }

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

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

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }

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

            try
            {
                DeskQuote.Area = DeskQuote.surfaceCalc();
                DeskQuote.Cost = DeskQuote.totalCalc();
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeskQuoteExists(DeskQuote.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            DeskQuote.Desk.DesktopMaterialID = Convert.ToInt16(selectedMaterial);
            DeskQuote.DaysToCompleteID       = Convert.ToInt16(selectedDays);

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

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

            return(RedirectToPage("./Index"));
        }
Exemple #5
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());
            }

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

            try
            {
                Deskquote.Area         = Deskquote.CalculateArea();
                Deskquote.AreaCost     = Deskquote.CalculateAreaCost();
                Deskquote.Material     = Request.Form["material"];
                Deskquote.MaterialCost = Deskquote.CalculateMaterialCost(Deskquote.Material);
                Deskquote.DrawerCost   = Deskquote.Drawers * Deskquote.COST_PER_DRAWER;
                Deskquote.Rush         = Request.Form["rush"];
                Deskquote.ShippingCost = Deskquote.CalculateShippingCost(Deskquote.Rush, Deskquote.Area);
                Deskquote.Quote        = Deskquote.CalculateQuoteTotal();
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeskquoteExists(Deskquote.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #6
0
        // To protect from overposting attacks, 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.QuotePrice = DeskQuote.GetDeskQuote(_context);
            DeskQuote.QuoteDate  = DateTime.Now;

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

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

            return(RedirectToPage("./Index"));
        }
Exemple #7
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());
            }

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

            try
            {
                Order.QuoteTotal = Order.getTotalCost();
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(Order.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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());
            }

            Desk.DesktopMaterial = _context.DesktopMaterial.Where(m => m.DesktopMaterialId == Desk.DesktopMaterialId).FirstOrDefault();
            _context.Desk.Add(Desk);
            await _context.SaveChangesAsync();

            DeskQuote.DeskId     = Desk.DeskId;
            DeskQuote.Desk       = Desk;
            DeskQuote.QuoteDate  = DateTime.Now;
            DeskQuote.QuotePrice = DeskQuote.GetDeskQuote(_context);

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

            return(RedirectToPage("./Index"));
        }
Exemple #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());
            }

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

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.DeskQuote.Add(DeskQuote);
            this.DeskQuote.Area = DeskQuote.areaCalc();
            this.DeskQuote.Cost = DeskQuote.totalCalc();
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #11
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
Exemple #12
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
Exemple #13
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
        // 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());
            }

            if (Order.SurfaceMaterial is "Oak")
            {
            }

            Order.QuoteTotal = Order.getTotalCost();

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

            return(RedirectToPage("./Index"));
        }
Exemple #15
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());
            }

            _context.Desk.Add(Desk);

            // DO LOGIC

            DeskQuote deskQuote = new DeskQuote();

            _context.DeskQuote.Add(deskQuote);
            // FINISH LOGIC

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, 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.QuoteDate = DateTime.Now;

            // Get the material for calculating the price
            DeskQuote.Desk.DesktopMaterial = _context.DesktopMaterial
                                             .FirstOrDefault(d => d.DesktopMaterialId == DeskQuote.Desk.DesktopMaterialId);
            // Get the delivery option for calculating the price
            DeskQuote.DeliveryOption = _context.DeliveryOption
                                       .FirstOrDefault(d => d.DeliveryOptionId == DeskQuote.DeliveryOptionId);

            DeskQuote.QuotePrice = DeskQuote.CalculatePriceQuote();

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

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

            return(RedirectToPage("./Index"));
        }
Exemple #17
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.Area     = Deskquote.CalculateArea();
            Deskquote.AreaCost = Deskquote.CalculateAreaCost();

            Deskquote.Material     = Request.Form["material"];
            Deskquote.MaterialCost = Deskquote.CalculateMaterialCost(Deskquote.Material);

            Deskquote.DrawerCost   = Deskquote.Drawers * Deskquote.COST_PER_DRAWER;
            Deskquote.Rush         = Request.Form["rush"];
            Deskquote.ShippingCost = Deskquote.CalculateShippingCost(Deskquote.Rush, Deskquote.Area);
            Deskquote.Quote        = Deskquote.CalculateQuoteTotal();


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

            return(RedirectToPage("./Index"));
        }
Exemple #18
0
        public async Task <IActionResult> OnPostAsync()
        {
            decimal deskPrice   = (decimal)this.BASE_PRICE;
            decimal surfaceArea = Desk.Width * Desk.Depth;

            int[] PRICES = { 60, 70, 80, 40, 50, 60, 30, 35, 40 };

            // Begin Calculations
            deskPrice += Desk.NumberOfDrawers * 50M;

            if (surfaceArea > 1000M)
            {
                deskPrice += surfaceArea - 1000M;
            }

            if (selectedMaterial == "Oak")
            {
                deskPrice += 200M;
            }
            else if (selectedMaterial == "Laminate")
            {
                deskPrice += 100M;
            }
            else if (selectedMaterial == "Pine")
            {
                deskPrice += 50M;
            }
            else if (selectedMaterial == "Rosewood")
            {
                deskPrice += 300M;
            }
            else if (selectedMaterial == "Veneer")
            {
                deskPrice += 125M;
            }

            if (selectedDays == "3 days (rush)")
            {
                if (surfaceArea < 1000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[0]);
                }
                else if (surfaceArea <= 2000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[1]);
                }
                else
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[2]);
                }
            }
            else if (selectedDays == "5 days (rush)")
            {
                if (surfaceArea < 1000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[3]);
                }
                else if (surfaceArea <= 2000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[4]);
                }
                else
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[5]);
                }
            }
            else if (selectedDays == "7 days (rush)")
            {
                if (surfaceArea < 1000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[6]);
                }
                else if (surfaceArea <= 2000)
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[7]);
                }
                else
                {
                    deskPrice += System.Convert.ToDecimal(PRICES[8]);
                }
            }
            DeskQuote.FinalPrice = deskPrice;

            DeskQuote.Date             = DateTime.Now;
            Desk.DesktopMaterialID     = Convert.ToInt16(selectedMaterial);
            DeskQuote.DaysToCompleteID = Convert.ToInt16(selectedDays);

            var returnedEntity = _context.Desk.Add(Desk);

            DeskQuote.DeskID = returnedEntity.Entity.ID;
            DeskQuote.Desk   = Desk;
            _context.DeskQuote.Add(DeskQuote);
            await _context.SaveChangesAsync();

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