// 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()); //return await this.OnGetAsync(this.id); //return RedirectToPage("./DeskQuotes/Edit"); } //DeskQuote.Price = DeskQuote.GetQuote(_context); _context.Attach(DeskQuote).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskQuoteExists(DeskQuote.DeskQuoteId)) { 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(Desk).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskExists(Desk.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(int?id) { if (!ModelState.IsValid) { return(Page()); } _context.Attach(DeskQuote).State = EntityState.Modified; try { var QuoteFromDB = await _context.DeskQuote.FindAsync(DeskQuote.DeskQuoteId); var DeskFromDB = await _context.Desk.FindAsync(DeskQuote.DeskId); DeskFromDB = Desk; //set desk QuoteFromDB.Desk = DeskFromDB; QuoteFromDB.QuoteDate = DateTime.Today; //set quote price QuoteFromDB.QuotePrice = DeskQuote.GetQuotePrice(_context); QuoteFromDB = DeskQuote; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskQuoteExists(DeskQuote.DeskQuoteId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }