public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.CustomerOrder.Add(CustomerOrder); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } CustomerOrder = await _context.CustomerOrder.FindAsync(id); if (CustomerOrder != null) { _context.CustomerOrder.Remove(CustomerOrder); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(CustomerOrder).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_context.CustomerOrder.Any(e => e.ID == CustomerOrder.ID)) { return(NotFound()); } throw; } return(RedirectToPage("./Index")); }
public async Task Add(TModel entity) { await _customerOrderContext.AddAsync <TModel>(entity); await _customerOrderContext.SaveChangesAsync(); }
public Task <int> CompleteAsync() { return(_context.SaveChangesAsync()); }