UserWindowVM.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections.ObjectModel;
  7. namespace Task1.ViewModel
  8. {
  9. class UserWindowVM : BaseViewModel
  10. {
  11. private ObservableCollection<User> _users;
  12. private User _user;
  13. private string _fio;
  14. private string _phone;
  15. private string _login;
  16. private RelayCommand _listTask;
  17. private RelayCommand _exit;
  18. public RelayCommand Exit
  19. {
  20. get
  21. {
  22. return _exit ??
  23. (_exit = new RelayCommand((x) =>
  24. {
  25. new MainWindow().Show();
  26. Helper.CloseWindowsAtType<UserWindow>();
  27. }));
  28. }
  29. }
  30. public RelayCommand ListTask
  31. {
  32. get
  33. {
  34. return _listTask??
  35. (_listTask = new RelayCommand((x) =>
  36. {
  37. new TaskWindow().Show();
  38. Helper.CloseWindowsAtType<UserWindow>();
  39. }));
  40. }
  41. }
  42. public ObservableCollection<User> Users
  43. {
  44. get => _users;
  45. set
  46. {
  47. _users = value;
  48. OnPropertyChanged();
  49. }
  50. }
  51. public User User
  52. {
  53. get => _user;
  54. set
  55. {
  56. _user = value;
  57. OnPropertyChanged();
  58. }
  59. }
  60. public string FIO
  61. {
  62. get => _fio = User.AUser.Surname + " " + User.AUser.Name + " " + User.AUser.Patronimyc;
  63. }
  64. public string Phone
  65. {
  66. get => _phone = User.AUser.Phone;
  67. }
  68. public string Login
  69. {
  70. get => _login = User.AUser.Login;
  71. }
  72. public UserWindowVM()
  73. {
  74. TaskContext taskContext = new TaskContext();
  75. _users = new ObservableCollection<User>(taskContext.Users);
  76. _user = new User();
  77. }
  78. }
  79. }