Esempio n. 1
0
        static void Main(string[] args)
        {
            ITodoRepository _repository = new TodoRepositoryInMemory();
            List <Todo>     todos       = new List <Todo>();

            todos = _repository.GetAll();
            //[1] 기본 데이터 출력
            foreach (var t in todos)
            {
                Console.WriteLine($"{t.Id} - {t.Title}({t.IsDone})");
            }
            Console.WriteLine();
            //[2] 데이터 입력
            Todo todo = new Todo {
                Title = "Database 학습", IsDone = true
            };

            _repository.Add(todo);
            todos = _repository.GetAll(); // 다시 로드
            //[3] 변경 데이터 출력
            foreach (var t in todos)
            {
                Console.WriteLine($"{t.Id} - {t.Title}({t.IsDone})");
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ITodoRepository _repository = new TodoRepositoryInMemory();

            List <Todo> todos = new List <Todo>();

            todos = _repository.GetAll();

            // 기본 데이터 출력
            foreach (var t in todos)
            {
                System.Console.WriteLine($"GetAll: {t.Id} - {t.Title} ({t.IsDone})");
            }

            // 데이터 입력
            Todo todo = new Todo {
                Title = "Database 학습", IsDone = true
            };

            _repository.Add(todo);

            // 다시 로드
            todos = _repository.GetAll();

            // 추가 데이터 출력
            foreach (var t in todos)
            {
                System.Console.WriteLine($"GetAll: {t.Id} - {t.Title}({t.IsDone})");
            }

            // 특정 데이터 출력
            todo = _repository.GetById(3);
            System.Console.WriteLine($"GetById: {todo.Id} - {todo.Title}({todo.IsDone})");
        }