TestResultViewModel.cs 987 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using CommunityToolkit.Mvvm.ComponentModel;
  6. using EntranseTesting.Models;
  7. using Microsoft.EntityFrameworkCore;
  8. using MsBox.Avalonia;
  9. using ReactiveUI;
  10. namespace EntranseTesting.ViewModels
  11. {
  12. public partial class TestResultViewModel : ObservableObject
  13. {
  14. [ObservableProperty] UserSession session = new UserSession();
  15. public TestResultViewModel() { }
  16. public TestResultViewModel(int? _n)
  17. {
  18. try
  19. {
  20. EntranceTestingContext connection = new EntranceTestingContext();
  21. Session = connection.UserSessions.Include(tb => tb.UserResponses).Include(tb => tb.IdAppSettingsNavigation).FirstOrDefault(tb => tb.Id == Response.userSession.Id);
  22. }
  23. catch (Exception ex)
  24. {
  25. #if DEBUG
  26. Debug.WriteLine("\n\nTestResult\n" + ex.Message);
  27. #endif
  28. }
  29. }
  30. }
  31. }