private async Task LoadSubjectDataList()
        {
            SubjectDataService subjectDataService = new SubjectDataService(new EntityFramework.TimetableManagerDbContext());

            SubjectList = await subjectDataService.GetSubjectsAsync();

            SubjectList.ForEach(e =>
            {
                SubjectDataList.Add(e);
            });
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Subject selectedSubject = (Subject)SubjectDataGrid.SelectedItem;

            SubjectDataService subjectDataService = new SubjectDataService(new EntityFramework.TimetableManagerDbContext());

            subjectDataService.DeleteSubject(selectedSubject.Id).ContinueWith(result =>
            {
                if (result == null)
                {
                    MessageBox.Show("Unable to Delete!", "Error");
                }
            });

            _ = SubjectDataList.Remove(selectedSubject);
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (SubjectNameTextBox.Text.Trim() == "" || SubjectCodeTextBox.Text.Trim() == "" || LectureHoursTextBox.Text.Trim() == "" || TutorialHoursTextBox.Text.Trim() == "" || LabHoursTextBox.Text.Trim() == "" || EvaluationHoursTextBox.Text.Trim() == "" || YearSemesterComboBox.SelectedItem == null)
            {
                MessageBox.Show("Sorry! Fields cannot be empty!", "Error");
                return;
            }

            Subject subject = new Subject
            {
                SubjectName         = SubjectNameTextBox.Text.Trim(),
                SubjectCode         = SubjectCodeTextBox.Text.Trim(),
                LectureHours        = Int32.Parse(LectureHoursTextBox.Text.Trim()),
                TutorialHours       = Int32.Parse(TutorialHoursTextBox.Text.Trim()),
                LabHours            = Int32.Parse(LabHoursTextBox.Text.Trim()),
                EvaluationHours     = Int32.Parse(EvaluationHoursTextBox.Text.Trim()),
                OfferedYearSemester = YearSemesterComboBox.SelectedItem.ToString()
            };

            SubjectDataService subjectDataService = new SubjectDataService(new EntityFramework.TimetableManagerDbContext());

            if (SubjectCodeTextBox.IsEnabled)
            {
                subjectDataService.AddSubject(subject).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Subject Added!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Error occured!", "Error");
                    }
                });
            }
            else
            {
                SubjectCodeTextBox.IsEnabled = true;
                subjectDataService.UpdateSubject(subject).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Subject Updated!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Error occured!", "Error");
                    }
                });
            }


            SubjectNameTextBox.Clear();
            SubjectCodeTextBox.Clear();
            LectureHoursTextBox.Clear();
            TutorialHoursTextBox.Clear();
            LabHoursTextBox.Clear();
            EvaluationHoursTextBox.Clear();
            YearSemesterComboBox.SelectedIndex = -1;

            SubjectDataList.Clear();
            _ = LoadSubjectDataList();
        }