Exemple #1
0
        public IActionResult GetProductCollection([ModelBinder(BinderType = typeof(ArrayModelBinder))] IEnumerable <int> ids)
        {
            if (ids == null)
            {
                return(BadRequest());
            }

            var productEntities = _supermarketRepository.GetProductsByIds(ids);

            if (ids.Count() != productEntities.Count())
            {
                return(NotFound());
            }

            var productsToReturn = Mapper.Map <IEnumerable <ProductDTO> >(productEntities);

            return(Ok(productsToReturn));
        }