TestSettingsViewModel.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Avalonia.Controls;
  5. using CommunityToolkit.Mvvm.ComponentModel;
  6. using CommunityToolkit.Mvvm.Input;
  7. using EntranseTesting.Models;
  8. using Microsoft.EntityFrameworkCore;
  9. using ReactiveUI;
  10. namespace EntranseTesting.ViewModels
  11. {
  12. public partial class TestSettingsViewModel : ObservableObject
  13. {
  14. [ObservableProperty]AppSetting? settings;
  15. [ObservableProperty]int countQuestion = 0;
  16. public TestSettingsViewModel()
  17. {
  18. EntranceTestingContext baseConnection = new EntranceTestingContext();
  19. if (baseConnection.AppSettings.ToList().Count > 0)
  20. Settings = baseConnection.AppSettings.ToList().Last();
  21. else
  22. {
  23. Settings = new AppSetting()
  24. {
  25. Time = new TimeSpan(0, 45, 0),
  26. CountOfQuestions = 30,
  27. HintVisibility = false,
  28. CountOfHints = 0,
  29. Raiting5 = 30,
  30. Raiting4 = 23,
  31. Raiting3 = 16
  32. };
  33. }
  34. CountQuestion = baseConnection.Questions.Where(tb => tb.InTest == true).Count();
  35. }
  36. }
  37. }