コード例 #1
0
        public async Task CompleteOrder(string orderId)
        {
            ShopApp.Models.Order order = this.Get(orderId);

            order.Status = OrderStatus.Completed;

            await this.dbContext.SaveChangesAsync();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }