private void addProjectButton_Click(object sender, EventArgs e)
        {
            DateTime?deadline = null;

            if (hasDeadlineCheckBox.Checked)
            {
                deadline = deadlineDateTimePicker.Value;
            }
            string title           = titleTextBox.Text;
            var    registerProject = new RegisterProject(title, deadline);

            try
            {
                _commandDispatcher.Send(registerProject);

                if (ProjectRegistered != null)
                {
                    var eventArgs = new ProjectRegisteredEventArgs(title, deadline);
                    ProjectRegistered(this, eventArgs);
                }
                Close();
            }
            catch (ProjectWithSameTitleExistsException ex)
            {
                _logger.Error(ex, "A project with title {title} already exists", registerProject.Title);
                MessageBox.Show("A project with this title already exists", "Error", MessageBoxButtons.OK);
            }
        }
Beispiel #2
0
        private void addProjectForm_ProjectRegistered(object sender, ProjectRegisteredEventArgs e)
        {
            AddProjectToTreeView(e.Title);

            string deadline  = e.Deadline.HasValue ? e.Deadline.ToString() : null;
            var    projectId = ProjectId.Create(e.Title);

            _projects.Add(new ProjectTreeNode(projectId, e.Title, deadline, "none", 0));

            if (projectTree.SelectedNode == null)
            {
                var project      = _projects.Find(x => x.Id == projectId);
                var selectedNode = projectTree.Nodes[project.Title];
                _selectedProjectId       = project.Id;
                projectTree.SelectedNode = selectedNode;
                if (ProjectSelected != null)
                {
                    var eventArgs = new ProjectSelectedEventArgs(_selectedProjectId);
                    ProjectSelected(this, eventArgs);
                }
            }
        }