Example #1
0
 public async Task <List <Models.Order> > GetOrders(DTO.OrderFilter order)
 {
     return(await ordersDbContext.Order
            .Where(o => (order.Today && o.DeliveryRequestedDate.Date == DateTime.Today) || !order.Today)
            .Where(o => (order.IdRestaurant.HasValue && order.IdRestaurant.Value == o.IdRestaurant) || !order.IdRestaurant.HasValue)
            .Where(o => (order.Status.HasValue && (int)order.Status.Value == o.IdStatus) || !order.Status.HasValue)
            .Where(o => (order.IdUser.HasValue && order.IdUser.Value == o.IdUser) || !order.IdUser.HasValue)
            .ToListAsync());
 }
Example #2
0
        public async Task <IActionResult> GetUserOrders(
            [FromRoute] int idUser,
            [FromQuery] DTO.OrderFilter order
            )
        {
            order.IdUser = idUser;
            var result = await ordersService.GetOrders(order);

            return(Ok(result));
        }
Example #3
0
        public async Task <IActionResult> GetRestaurantsOrders(
            [FromRoute] int idRestaurant,
            [FromQuery] DTO.OrderFilter order
            )
        {
            order.IdRestaurant = idRestaurant;
            var result = await ordersService.GetOrders(order);

            return(Ok(result));
        }