public IActionResult Index([FromQuery] int?id) { if (id is null) { return(Ok(_ordersRepository.GetOrders())); } var order = _ordersRepository.GetOrderById((int)id); var products = _linksRepository.GetProductIds(order.Id) .Select(p => _productsRepository.GetProductById(p)); return(Ok(new { order, products })); }