Ejemplo n.º 1
0
        public IActionResult GetAllOrdersByUserId(int userId)
        {
            var validUser = _usersRepository.GetUserById(userId);

            if (validUser != null)
            {
                var orders  = _ordersRepository.GetUserOrders(userId);
                var isEmpty = !orders.Any();
                if (isEmpty)
                {
                    return(NotFound("This user does not have any orders."));
                }
                return(Ok(orders));
            }
            return(NotFound("That user does not exist"));
        }