Created
June 2, 2012 15:56
-
-
Save codeprogression/2858924 to your computer and use it in GitHub Desktop.
In memory place repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Repository | |
{ | |
private static readonly IList<Place> Places = new List<Place> | |
{ | |
new Place(0, "Pastini Pastaria", "Lunch", "Dinner", "Pasta", "Beer", "Wine"), | |
new Place(1, "Deschutes Brewery", "Lunch", "Dinner", "Pasta", "Beer", "Wine"), | |
new Place(2, "Stumptown Coffee", "Breakfast", "Coffee"), | |
new Place(3, "Voodoo Doughnuts", "Breakfast", "Coffee"), | |
new Place(4, "J Cafe", "Breakfast", "Lunch", "Coffee"), | |
}; | |
public void AddPlace(string name, params string[] tags) | |
{ | |
var id = Places.Any()? Places.Max(x=>x.Id) + 1 : 0; | |
var place = new Place(id, name,tags); | |
Places.Add(place); | |
} | |
public ReadOnlyCollection<Place> GetPlaces() | |
{ | |
return new ReadOnlyCollection<Place>(Places); | |
} | |
public Place GetPlace(int id) | |
{ | |
return Places.SingleOrDefault(x=>x.Id == id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment