public async Task <IActionResult> GetAll([FromQuery] string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                return(Ok((await _groceryListItemService.GetSuggestions(text)).ToApiModels()));
            }

            var all = await _groceryListItemService.GetAll();

            return(Ok(all.ToApiModels()));
        }
Beispiel #2
0
        public async Task <ActionResult <IEnumerable <GroceryListItem> > > GetGroceryListItems()
        {
            var listItems = await _groceryListItemService.GetAll();

            GroceryListItem _listItem;
            var             _listItems = new List <GroceryListItem>();

            foreach (var item in listItems)
            {
                _listItem = new GroceryListItem()
                {
                    Id           = item.Id,
                    Quantity     = item.Quantity,
                    DateCreated  = item.DateCreated,
                    ProductTitle = item.Product.Title,
                    ProductSlug  = item.Product.Slug,
                    ProductImage = Image.Generate(item.Product.ImageData, item.Product.ImageType)
                };

                _listItems.Add(_listItem);
            }

            return(Ok(_listItems));
        }