public async Task <IActionResult> Containers([FromQuery(Name = "from")] int from = 0, [FromQuery(Name = "to")] int to = 4) { var quantity = to - from; if (quantity <= 0) { return(BadRequest("You cannot have the 'to' parameter higher than 'from' parameter.")); } if (from < 0) { return(BadRequest("You cannot go in the negative with the 'from' parameter")); } var allContainers = await containerProvider.GetList(); var result = new { Total = allContainers.Count, Containers = allContainers.Skip(from).Take(quantity).ToArray() }; return(Ok(result)); }