public IActionResult GetMaterials(
            [FromQuery] bool getAll         = false,
            [FromQuery] int page            = 1,
            [FromQuery] int elementsPerPage = 10,
            [FromQuery] string search       = null,
            [FromQuery] string manufacturer = null,
            [FromQuery] string type         = null)
        {
            if (!getAll && (page < 1 || elementsPerPage < 1))
            {
                return(HandleBadRequest("Bad pagination parameters."));
            }

            // Check for material type validity
            Plastic plastic = null;

            if (type != null)
            {
                try
                {
                    plastic = PlasticsService.GetPlastic(type);
                }
                catch (PlasticNotFoundException exception)
                {
                    return(HandleBadRequest(exception.Message));
                }
            }

            // Get, filter and paginate materials
            try
            {
                IEnumerable <Material> materials          = MaterialsService.GetMaterials(search, manufacturer, plastic);
                IEnumerable <Material> paginatedMaterials = materials;
                if (!getAll)
                {
                    paginatedMaterials = materials.Skip((page - 1) * elementsPerPage).Take(elementsPerPage);
                }
                return(Ok(new PaginatedResponse(paginatedMaterials, materials.Count())));
            }
            catch (Exception exception)
            {
                return(HandleUnexpectedException(exception));
            }
        }