public async Task <IActionResult> DeleteItemAsync(int id) { if (await _fridgeItemRepository.DeleteAsync(id)) { return(NoContent()); } return(NotFound()); }
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); }