public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DeskModel = await _context.DeskModel.FindAsync(id); if (DeskModel != null) { _context.DeskModel.Remove(DeskModel); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } getArea(); getDrawerCost(); getMaterialCost(); getRushCost(); getTotalCost(); Desk.Date = DateTime.Now.ToString("MM/dd/yyyy"); _context.DeskModel.Add(Desk); 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()); } getArea(); getDrawerCost(); getMaterialCost(); getRushCost(); getTotalCost(); //*****Save****// _context.Attach(Desk).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskModelExists(Desk.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); /*******************/ }