Skip to content

Instantly share code, notes, and snippets.

@codeprogression
Created June 2, 2012 15:56
Show Gist options
  • Save codeprogression/2858924 to your computer and use it in GitHub Desktop.
Save codeprogression/2858924 to your computer and use it in GitHub Desktop.
In memory place repository
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