Example #1
0
        public async Task <List <OrderWithStatus> > GetOrders(string userId)
        {
            var orders = await _db.Orders
                         .Where(o => o.UserId == userId)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
Example #2
0
        public async Task <OrderWithStatus> GetOrderWithStatus(int orderId, string userId)
        {
            var order = await _db.Orders
                        .Where(o => o.OrderId == orderId)
                        .Where(o => o.UserId == userId)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                        .SingleOrDefaultAsync();

            if (order == null)
            {
                return(null);
            }

            return(OrderWithStatus.FromOrder(order));
        }