// 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(Desk).State = EntityState.Modified; DeskQuote.Desk = Desk.ID; _context.Attach(DeskQuote).State = EntityState.Modified; DeskQuote.QuotePrice = DeskQuote.GetQuotePrice(_context); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskQuoteExists(DeskQuote.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()); } _context.Desk.Add(Desk); await _context.SaveChangesAsync(); DeskQuote.Desk = Desk.ID; DeskQuote.Date = DateTime.Now; DeskQuote.QuotePrice = DeskQuote.GetQuotePrice(_context); _context.DeskQuote.Add(DeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?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")); }