summaryrefslogtreecommitdiff
path: root/src/MVPtoMVVM/repositories/TodoItemRepository.cs
blob: 6029ad43ddafb1de038877640c66bc19cb76a638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using MVPtoMVVM.domain;
using System.Linq;

namespace MVPtoMVVM.repositories
{
    public class TodoItemRepository : ITodoItemRepository
    {
        private List<TodoItem> items;

        public TodoItemRepository()
        {
            items = new List<TodoItem>();
            items.Add(new TodoItem {Description = "First One", DueDate = DateTime.Today});
        }

        public void Add(TodoItem item)
        {
            items.Add(item);
        }

        public TodoItem Get(string description)
        {
            return items.FirstOrDefault(x => x.Description == description);
        }

        public IEnumerable<TodoItem> GetAll()
        {
            return items.AsEnumerable();
        }
    }
}