Example #1
0
        private void btnAddNewTask_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNewTask.Text))
            {
                TodoTask task = new TodoTask
                                    {
                                        DateCompleted = DateTime.Now,
                                        DateEntered = DateTime.Now,
                                        Description = txtNewTask.Text,
                                        Importance = GetImporance(),
                                        Notes = string.Empty
                                    };

                _presenter.AddTask(task);

                txtNewTask.Text = string.Empty;

                listBoxTasks.Items.Clear();

                foreach(TodoTask temporaryTask in _presenter.GetUnfinishedTasks(Importance.All))
                {
                    listBoxTasks.Items.Add(temporaryTask);
                }
            }
        }
        public void Fill()
        {
            _list = new List<TodoTask>();

            try
            {
                if (File.Exists(_fileLocator.GetFilePath()))
                {
                    using (StreamReader reader = new StreamReader(_fileLocator.GetFilePath()))
                    {
                        while (reader.Peek() != -1)
                        {
                            string line = reader.ReadLine();

                            string[] items = line.Split(',');

                            TodoTask task = new TodoTask();

                            DateTime dateEntered;
                            DateTime.TryParse(items[0], out dateEntered);
                            DateTime dateCompleted;
                            DateTime.TryParse(items.Length > 3 ? items[3] : items[0], out dateCompleted);

                            task.DateEntered = dateEntered;
                            task.DateCompleted = dateCompleted;
                            task.Description = items[1];
                            task.Importance = GetImportance(items.Length > 2 ? items[2] : "1");
                            task.Notes = items.Length > 4 ? items[4] : string.Empty;

                            _list.Add(task);

                        }
                    }

                }

            }
            catch (Exception exception)
            {
                throw new Exception("Failed while reading: " + _fileLocator.GetFilePath(), exception);
            }
        }
 public void CompleteTask(TodoTask todoTask)
 {
     todoTask.Notes = _input.GetEntry("Question", "Resolution Notes");
     todoTask.DateCompleted = DateTime.Now;
     _hasChanges = true;
 }
 public void AddTask(TodoTask todoTask)
 {
     _taskRepo.Add(todoTask);
     _hasChanges = true;
 }
Example #5
0
 public void Add(TodoTask task)
 {
     _list.Add(task);
 }