public async Task CompleteOrder(string orderId) { ShopApp.Models.Order order = this.Get(orderId); order.Status = OrderStatus.Completed; await this.dbContext.SaveChangesAsync(); }
public ShopApp.Models.Order Get(string id) { ShopApp.Models.Order order = this.dbContext.Orders.FirstOrDefault(o => o.Id == id); if (order == null) { throw new InvalidOperationException("Invalid order ID."); } return(order); }
public async Task CancelOrder(string orderId) { ShopApp.Models.Order order = this.dbContext.Orders.Include(o => o.User).FirstOrDefault(o => o.Id == orderId); if (order == null) { throw new InvalidOperationException("Invalid Order ID."); } this.dbContext.Orders.Remove(order); await this.dbContext.SaveChangesAsync(); }