diff --git a/LangLang/WPF/ViewModels/DirectorViewModels/DirectorWindowViewModel.cs b/LangLang/WPF/ViewModels/DirectorViewModels/DirectorWindowViewModel.cs new file mode 100644 index 0000000..ea987f3 --- /dev/null +++ b/LangLang/WPF/ViewModels/DirectorViewModels/DirectorWindowViewModel.cs @@ -0,0 +1,20 @@ +using LangLang.WPF.Views.DirectorView.Tabs; + +namespace LangLang.WPF.ViewModels.DirectorViewModels +{ + public class DirectorWindowViewModel + { + public DirectorWindowViewModel() {} + + public void UpdateCourses(CoursesReview coursesTab) + { + coursesTab.Update(); + } + + public void UpdateExams(ExamSlotsReview examsTab) + { + examsTab.Update(); + } + + } +} diff --git a/LangLang/WPF/Views/DirectorView/DirectorWindow.xaml.cs b/LangLang/WPF/Views/DirectorView/DirectorWindow.xaml.cs index dad9fe3..b3dbd46 100644 --- a/LangLang/WPF/Views/DirectorView/DirectorWindow.xaml.cs +++ b/LangLang/WPF/Views/DirectorView/DirectorWindow.xaml.cs @@ -1,18 +1,25 @@ -using System.Windows; -using System.Windows.Controls; using LangLang.BusinessLogic.UseCases; using LangLang.Domain.Models; +using LangLang.WPF.ViewModels.DirectorViewModels; using LangLang.WPF.Views.DirectorView.Tabs; +using LangLang.WPF.Views.StudentView.Tabs; +using System.Windows; +using System.Windows.Controls; namespace LangLang.WPF.Views.DirectorView { public partial class DirectorWindow : Window { public Director CurrentlyLoggedIn { get; set; } + public CoursesReview coursesTab { get; set; } + public ExamSlotsReview examsTab { get; set; } + public DirectorWindowViewModel ViewModel { get; set; } + public DirectorWindow(Profile currentlyLoggedIn) { InitializeComponent(); - DataContext = this; + ViewModel = new DirectorWindowViewModel(); + DataContext = ViewModel; var directorService = new DirectorService(); CurrentlyLoggedIn = directorService.Get(currentlyLoggedIn.Id); GenerateTabs(); @@ -20,7 +27,7 @@ public DirectorWindow(Profile currentlyLoggedIn) private void GenerateTabs() { - var reviewTab = new TutorReview(); + var reviewTab = new TutorReview(this); AddTab("Tutor review", reviewTab); var resultsTab = new ResultsSending(); AddTab("Results Sending", resultsTab); @@ -28,12 +35,18 @@ private void GenerateTabs() AddTab("Graded courses", gradedCoursesTab); var reportsTab = new Reports(CurrentlyLoggedIn); AddTab("Reports", reportsTab); - var coursesTab = new CoursesReview(); + coursesTab = new CoursesReview(); AddTab("Courses", coursesTab); - var examsTab = new ExamSlotsReview(); + examsTab = new ExamSlotsReview(); AddTab("Exams", examsTab); } + public void Update() + { + ViewModel.UpdateCourses(coursesTab); + ViewModel.UpdateExams(examsTab); + } + private void AddTab(string header, UserControl content) { TabItem tabItem = new() diff --git a/LangLang/WPF/Views/DirectorView/Tabs/TutorReview.xaml.cs b/LangLang/WPF/Views/DirectorView/Tabs/TutorReview.xaml.cs index 39e43e8..788082a 100644 --- a/LangLang/WPF/Views/DirectorView/Tabs/TutorReview.xaml.cs +++ b/LangLang/WPF/Views/DirectorView/Tabs/TutorReview.xaml.cs @@ -8,10 +8,12 @@ namespace LangLang.WPF.Views.DirectorView.Tabs public partial class TutorReview : UserControl { public TutorReviewPageViewModel TutorReviewViewModel { get; set; } + private DirectorWindow _parent; - public TutorReview() + public TutorReview(DirectorWindow parent) { InitializeComponent(); + _parent = parent; TutorReviewViewModel = new(); DataContext = TutorReviewViewModel; DisableButtons(); @@ -33,6 +35,7 @@ private void UpdateTutor_Click(object sender, RoutedEventArgs e) private void DeleteTutor_Click(object sender, RoutedEventArgs e) { TutorReviewViewModel.DeleteTutor(); + _parent.Update(); } private void Search_Click(object sender, RoutedEventArgs e)