Esempio n. 1
0
        public IHttpActionResult GetCars()
        {
            List <CarResponseDto> carResponseDtos = new List <CarResponseDto>();
            List <Product>        products        = _carService.GetCars();

            foreach (Product product in products)
            {
                carResponseDtos.Add(_carsMapper.ToDto(product));
            }

            return(Ok(carResponseDtos));
        }
Esempio n. 2
0
        public IHttpActionResult FilterCarOnPrice(FilterDecimalValues filterDecimalValues)
        {
            if (filterDecimalValues.LowerBound == null && filterDecimalValues.UpperBound == null)
            {
                return(BadRequest("lower bound and upper bound can't both be NULL"));
            }

            List <Product> filterCarsOnPrice = _carService.FilterCarsOnPrice(filterDecimalValues.LowerBound,
                                                                             filterDecimalValues.UpperBound);

            List <CarResponseDto> responseDtos = new List <CarResponseDto>();

            foreach (Product car in filterCarsOnPrice)
            {
                responseDtos.Add(_carsMapper.ToDto(car));
            }

            return(Ok(responseDtos));
        }