public async Task <IActionResult> GetItemsAsync() { IEnumerable <FridgeItem> items = await _fridgeItemRepository.GetAsync(); var resource = items.Select(Map); return(Ok(resource)); }
public async Task <IEnumerable <FridgeItem> > CleanAsync() { var allItems = await _itemRepository.GetAsync(); var expired = allItems .Where(i => i.ExpirationDate <= DateTime.Now) .ToList(); await _itemRepository.DeleteAsync(expired.Select(i => i.Id)); foreach (var item in expired) { item.Id = 0; } return(expired); }