Exemplo n.º 1
0
        private void ModifyTask(object sender, ExecutedRoutedEventArgs e)
        {
            var selectedTask = (TaskTableItem)TasksGrid.SelectedItem;
            var modifyDialog = new Dialogs.AddModifyTaskDialog(selectedTask, _subjectRepository.GetAllSubjects());

            modifyDialog.ShowDialog();
            if (!modifyDialog.IsSelected)
            {
                return;
            }
            _taskRepository.ModifyTask(selectedTask.TaskTableItemTask.TaskId, modifyDialog.SelectedSubject.SubjectId,
                                       modifyDialog.SelectedDate, modifyDialog.SelectedTaskDescription,
                                       modifyDialog.SelectedTaskPriority);
            var targetTask =
                _displayedTaskTableItems.First(
                    task => task.TaskTableItemTask.TaskId == selectedTask.TaskTableItemTask.TaskId);

            targetTask.TaskTableItemSubject              = modifyDialog.SelectedSubject;
            targetTask.TaskTableItemTask.DeadLineDate    = modifyDialog.SelectedDate;
            targetTask.TaskTableItemTask.SubjectId       = modifyDialog.SelectedSubject.SubjectId;
            targetTask.TaskTableItemTask.TaskDescription = modifyDialog.SelectedTaskDescription;
            targetTask.TaskTableItemTask.TaskPriority    = modifyDialog.SelectedTaskPriority;

            TasksGrid.Items.Refresh();
        }
Exemplo n.º 2
0
        private void AddNewTask(object sender, RoutedEventArgs e)
        {
            var addDialog = new Dialogs.AddModifyTaskDialog(_subjectRepository.GetAllSubjects());

            addDialog.ShowDialog();
            if (!addDialog.IsSelected)
            {
                return;
            }
            int insertedTaskId = _taskRepository.AddNewTask(addDialog.SelectedSubject.SubjectId,
                                                            addDialog.SelectedTaskPriority,
                                                            addDialog.SelectedDate,
                                                            addDialog.SelectedTaskDescription);

            var newTask = new TaskTableItem()
            {
                TaskTableItemSubject = addDialog.SelectedSubject,
                TaskTableItemTask    = new SubjectTask()
                {
                    DeadLineDate    = addDialog.SelectedDate,
                    SubjectId       = addDialog.SelectedSubject.SubjectId,
                    TaskPriority    = addDialog.SelectedTaskPriority,
                    TaskDescription = addDialog.SelectedTaskDescription,
                    TaskId          = insertedTaskId
                }
            };

            if ((CertainSubjectTasks.IsChecked != null &&
                 (bool)CertainSubjectTasks.IsChecked &&
                 ((Subject)AwailableSubjects.SelectedItem).SubjectId == newTask.TaskTableItemSubject.SubjectId) ||
                (CertainSubjectTasks.IsChecked != null && !(bool)CertainSubjectTasks.IsChecked) ||
                CertainSubjectTasks.IsChecked == null)
            {
                _displayedTaskTableItems.Add(newTask);
            }
            TasksGrid.Items.Refresh();
        }