// 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(Quote).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuoteExists(Quote.ID)) { return(NotFound()); } else { throw; } } 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()); } UpdateMaterialCost(_context, DeskQuote.Desk.SurfaceMaterialId); UpdateShippingCost(_context, _configuration, DeskQuote.RushId, DeskQuote.Desk.SurfaceArea); DeskQuote.MaterialCost = MaterialCost; DeskQuote.ShippingCost = ShippingCost; _context.Attach(DeskQuote).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskQuoteExists(DeskQuote.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.Quote.Add(Quote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
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")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SurfaceMaterial = await _context.SurfaceMaterial.FindAsync(id); if (SurfaceMaterial != null) { _context.SurfaceMaterial.Remove(SurfaceMaterial); 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() { var emptyDeskQuote = new DeskQuote { Desk = new Desk { Width = DeskQuote.Desk.Width, Depth = DeskQuote.Desk.Depth, Drawers = DeskQuote.Desk.Drawers, SurfaceMaterialId = DeskQuote.Desk.SurfaceMaterialId }, BasePrice = Decimal.Parse(_configuration["Pricing:BasePrice"]), PricePerDrawer = Decimal.Parse(_configuration["Pricing:PricePerDrawer"]), PricePerSquareInch = Decimal.Parse(_configuration["Pricing:PricePerSquareInch"]), SurfacePriceFloor = int.Parse(_configuration["Pricing:SurfacePricingFloor"]), CreatedDate = DateTime.UtcNow }; if (await TryUpdateModelAsync <DeskQuote>( emptyDeskQuote, "deskquote", // Prefix for form value. s => s.CustomerName, s => s.RushId)) { UpdateMaterialCost(_context, emptyDeskQuote.Desk.SurfaceMaterialId); UpdateShippingCost(_context, _configuration, emptyDeskQuote.RushId, emptyDeskQuote.Desk.SurfaceArea); emptyDeskQuote.MaterialCost = MaterialCost; emptyDeskQuote.ShippingCost = ShippingCost; _context.DeskQuote.Add(emptyDeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }