Пример #1
0
        internal void addTask(Task task)
        {
            if (tasks == null)
            {
                tasks = new List<Task>(_dataStore.loadTasks());
            }

            tasks.Add(task);

            _dataStore.saveTasks(tasks.ToArray());
        }
Пример #2
0
        public void saveTasks(Task[] tasks)
        {
            string[] taskLines = new string[tasks.Length];

            for (int i = 0; i < tasks.Length; i++)
            {
                if (tasks[i].completedDate.HasValue)
                    taskLines[i] = String.Format("{0}|{1}|{2}|{3}", tasks[i].name, tasks[i].info, tasks[i].createDate.Ticks, tasks[i].completedDate.Value.Ticks);
                else
                    taskLines[i] = String.Format("{0}|{1}|{2}", tasks[i].name, tasks[i].info, tasks[i].createDate.Ticks);
            }

            File.WriteAllLines(_path, taskLines);
        }
Пример #3
0
        public IState run()
        {
            Console.Write("\nName: ");
            var name = Console.ReadLine();

            Console.Write("Info: ");

            var info = Console.ReadLine();

            var createDate = DateTime.UtcNow;

            var task = new Task(name, info, createDate);

            _tm.addTask(task);

            return new HomeState(_tm);
        }