Guest User

Untitled

a guest
Oct 16th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class Repository
  2. {
  3. private static readonly IList<Place> Places = new List<Place>
  4. {
  5. new Place(0, "Pastini Pastaria", "Lunch", "Dinner", "Pasta", "Beer", "Wine"),
  6. new Place(1, "Deschutes Brewery", "Lunch", "Dinner", "Pasta", "Beer", "Wine"),
  7. new Place(2, "Stumptown Coffee", "Breakfast", "Coffee"),
  8. new Place(3, "Voodoo Doughnuts", "Breakfast", "Coffee"),
  9. new Place(4, "J Cafe", "Breakfast", "Lunch", "Coffee"),
  10. };
  11.  
  12. public void AddPlace(string name, params string[] tags)
  13. {
  14. var id = Places.Any()? Places.Max(x=>x.Id) + 1 : 0;
  15. var place = new Place(id, name,tags);
  16. Places.Add(place);
  17. }
  18.  
  19. public ReadOnlyCollection<Place> GetPlaces()
  20. {
  21. return new ReadOnlyCollection<Place>(Places);
  22. }
  23.  
  24. public Place GetPlace(int id)
  25. {
  26. return Places.SingleOrDefault(x=>x.Id == id);
  27. }
  28. }
Add Comment
Please, Sign In to add comment