public AddModifyTaskDialog(TaskTableItem selectedTask, List <Subject> subjectList) { InitializeComponent(); AwailableSubjectsList.ItemsSource = subjectList; AwailableSubjectsList.SelectedItem = subjectList.First(subj => subj.SubjectId == selectedTask.TaskTableItemSubject.SubjectId); TaskDeadline.SelectedDate = selectedTask.TaskTableItemTask.DeadLineDate; TaskPriority.Text = selectedTask.TaskTableItemTask.TaskPriority.ToString(); TaskDescription.Text = selectedTask.TaskTableItemTask.TaskDescription; }
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(); }