Exemplo n.º 1
0
        private void buttonPickDate_Click(object sender, EventArgs e)
        {
            Action <DateTime> pickToDoListForDateAction = (pickedDate) =>
            {
                //Pick date and find 'ToDo List' for that date
                var listByDate = _toDoListDao.GetOneByDate(pickedDate);

                //If 'ToDo List' doesn't exist, create new one
                if (listByDate == null)
                {
                    var newList = _toDoListDao.Insert(ToDoList.New(pickedDate));
                    listByDate = newList;
                    _toDoListService.AddListToCache(listByDate);
                }

                // Create model for 'ToDoList' and display it
                flowLayoutPanel1.Controls.Clear();
                var listByDateModel = new ToDoListModel(listByDate);
                _currentToDoList = listByDateModel;

                var toDoListControl = new ToDoListControl(listByDateModel, _toDoListService, _toDoListDao, _toDoTaskDao);
                flowLayoutPanel1.Controls.Add(toDoListControl);
            };

            var datePickerForm = new DatePickerForm(pickToDoListForDateAction);

            datePickerForm.Show();
        }