Skip to content

Commit

Permalink
Merge pull request #223 from kzi-nastava/fix/table-display-in-the-exa…
Browse files Browse the repository at this point in the history
…m-slot-tab

[fix] display of table in ExamSlot tab
  • Loading branch information
anasinik authored Apr 29, 2024
2 parents 741ab73 + 7c95261 commit 72b4331
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
12 changes: 5 additions & 7 deletions LangLang/DTO/ExamSlotDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,14 @@ public bool IsValid



public ExamSlotDTO(ExamSlot examSlot, LanguageLevel level, string language, int tutorId, int numberStudents)
public ExamSlotDTO(ExamSlot examSlot)
{
this.Id = examSlot.Id;
this.Language = language;
this.Level = level;
this.TutorId = tutorId;
this.Language = examSlot.Language;
this.Level = examSlot.Level;
this.MaxStudents = examSlot.MaxStudents.ToString();
this.NumberStudents = numberStudents;
this.ExamDate = examSlot.TimeSlot.Time.Date;
this.Time = examSlot.TimeSlot.Time.ToString("HH:mm");
//this.ExamDate = examSlot.TimeSlot.Time.Date;
//this.Time = examSlot.TimeSlot.Time.ToString("HH:mm");
this.ApplicationPossible = examSlot.ApplicationPossible;
}

Expand Down
7 changes: 3 additions & 4 deletions LangLang/View/TutorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@
SelectedItem="{Binding SelectedExamSlot, UpdateSourceTrigger=PropertyChanged}"
SelectionMode="Single" IsReadOnly="True" SelectionChanged="ExamSlotsDataGrid_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="Course ID" Binding="{Binding CourseId}"/>
<DataGridTextColumn Header="Max Students" Binding="{Binding MaxStudents}"/>
<DataGridTextColumn Header="Number of Students" Binding="{Binding NumberOfStudents}"/>
<DataGridTextColumn Header="Date and Time" Binding="{Binding ExamDateTime, StringFormat={}{0:MM/dd/yyyy HH:mm}}"/>
<DataGridTextColumn Header="Language" Binding="{Binding Language}"/>
<DataGridTextColumn Header="Level" Binding="{Binding Level}"/>
<DataGridTextColumn Header="Max students" Binding="{Binding MaxStudents}"/>
</DataGrid.Columns>
</DataGrid>
<!--end of exam slots table-->
Expand Down
25 changes: 13 additions & 12 deletions LangLang/View/TutorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Collections.Generic;

namespace LangLang
{
Expand All @@ -19,7 +20,7 @@ public partial class TutorWindow : Window, IObserver
// EXAM SLOTS
public ObservableCollection<ExamSlotDTO> ExamSlots { get; set; }
public ExamSlotDTO SelectedExamSlot { get; set; }
private ExamSlotController examSlotsController { get; set; }
private ExamSlotController examSlotController { get; set; }

// COURSES
public ObservableCollection<CourseDTO> Courses { get; set; }
Expand All @@ -36,7 +37,7 @@ public TutorWindow(AppController appController, Profile currentlyLoggedIn)
DataContext = this;

this.appController = appController;
examSlotsController = appController.ExamSlotController;
examSlotController = appController.ExamSlotController;
coursesController = appController.CourseController;

ExamSlots = new ObservableCollection<ExamSlotDTO>();
Expand All @@ -46,42 +47,42 @@ public TutorWindow(AppController appController, Profile currentlyLoggedIn)
DisableButtonsCourse();

coursesController.Subscribe(this);
examSlotsController.Subscribe(this);
examSlotController.Subscribe(this);

Update();
}

public void Update()
{
ExamSlots.Clear();
//filter exam slots for this tutor
foreach (ExamSlot exam in examSlotsController.GetExamSlotsByTutor(tutor.Id, coursesController))

foreach (ExamSlot exam in examSlotController.GetExams(tutor))
{
Course c = coursesController.GetAllCourses()[exam.CourseId];
ExamSlots.Add(new ExamSlotDTO(exam, c));
ExamSlots.Add(new ExamSlotDTO(exam));
}

Courses.Clear();

foreach (Course course in coursesController.GetCoursesByTutor(tutor).Values)
Courses.Add(new CourseDTO(course));
coursesTable.ItemsSource = Courses;
}

private void ExamSlotCreateWindowBtn_Click(object sender, RoutedEventArgs e)
{
ExamSlotCreateWindow examSlotCreateWindow = new ExamSlotCreateWindow(coursesController.GetCoursesByTutor(tutor), examSlotsController);
ExamSlotCreateWindow examSlotCreateWindow = new ExamSlotCreateWindow(coursesController.GetCoursesByTutor(tutor), examSlotController);
examSlotCreateWindow.Show();
}

private void ExamSlotUpdateWindowBtn_Click(object sender, RoutedEventArgs e)
{
ExamSlotUpdateWindow examSlotUpdateWindow = new ExamSlotUpdateWindow(SelectedExamSlot, coursesController.GetCoursesByTutor(tutor), examSlotsController);
ExamSlotUpdateWindow examSlotUpdateWindow = new ExamSlotUpdateWindow(SelectedExamSlot, coursesController.GetCoursesByTutor(tutor), examSlotController);
examSlotUpdateWindow.Show();
}

private void CourseCreateWindowBtn_Click(object sender, RoutedEventArgs e)
{
CourseCreateWindow courseCreateWindow = new CourseCreateWindow(coursesController, examSlotsController, tutor.Id);
CourseCreateWindow courseCreateWindow = new CourseCreateWindow(coursesController, examSlotController, tutor.Id);
courseCreateWindow.ShowDialog();
Update();
}
Expand All @@ -95,7 +96,7 @@ private void CourseSearchWindowBtn_Click(object sender, RoutedEventArgs e)

private void ExamSlotDeleteBtn_Click(object sender, RoutedEventArgs e)
{
if (!examSlotsController.Delete(SelectedExamSlot.Id))
if (!examSlotController.Delete(SelectedExamSlot.Id))
{
MessageBox.Show("Can't delete exam, there is less than 14 days before exam.");
}
Expand All @@ -121,7 +122,7 @@ private void CourseDeleteBtn_Click(object sender, RoutedEventArgs e)
if (coursesController.IsCourseValid(SelectedCourse.Id))
{
int id = SelectedCourse.Id;
examSlotsController.DeleteExamSlotsByCourseId(id);
examSlotController.DeleteExamSlotsByCourseId(id);
coursesController.Delete(id);
Update();
MessageBox.Show("The course has successfully been deleted.");
Expand Down

0 comments on commit 72b4331

Please sign in to comment.