public async Task<Order> UpdateOrderAsync(Order order) { if (!_context.Orders.Local.Any(o => o.Id == order.Id)) { _context.Orders.Attach(order); } _context.Entry(order).State = EntityState.Modified; await _context.SaveChangesAsync(); return order; }
public async Task<Order> AddOrderAsync(Order order) { _context.Orders.Add(order); await _context.SaveChangesAsync(); return order; }