/// <summary> /// Get all restaurants with deferred execution. /// </summary> /// <returns>The collection of restaurants</returns> public IEnumerable <PizzaStore> GetStores(string search = null) { if (search == null) //no parameter defaults to returning each item { foreach (var item in locationRepo.GetAllT()) { yield return(Mapper.Map(item)); } } else { //or return each pizza restaurant with the given item in inventory (doesn't check quantity) PizzaStore store; foreach (var item in locationRepo.GetAllT()) { store = Mapper.Map(item); if (store.Inventory.ContainsKey(search)) { yield return(store); } } } }