Exemplo n.º 1
0
        public ActionResult <IEnumerable <ShoppingListDto> > GetShoppingLists(
            [FromQuery] ShoppingListResourceParameters shoppingListResourceParameters)
        {
            var shoppingListsFromRepo = _shopListingRepository.GetShoppingLists(shoppingListResourceParameters);

            return(Ok(_mapper.Map <IEnumerable <ShoppingListDto> >(shoppingListsFromRepo)));
        }
        public IActionResult GetShoppingListCollection(
            [FromRoute]
            [ModelBinder(BinderType = typeof(ArrayModelBinder))] IEnumerable <Guid> ids)
        {
            if (ids == null)
            {
                return(BadRequest());
            }

            var shoppingListEntities = _shopListingRepository.GetShoppingLists(ids);

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

            var shoppingListsToReturn = _mapper.Map <IEnumerable <ShoppingListDto> >(shoppingListEntities);

            return(Ok(shoppingListsToReturn));
        }