MainViewModel.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. namespace OUP
  8. {
  9. public class MainViewModel : BaseViewModel
  10. {
  11. private RelayCommand _authcommand;
  12. private string _login;
  13. private string _password;
  14. public string Login
  15. {
  16. get => _login;
  17. set
  18. {
  19. _login = value;
  20. OnPropertyChanged();
  21. }
  22. }
  23. public string Password
  24. {
  25. get => _password;
  26. set
  27. {
  28. _password = value;
  29. OnPropertyChanged();
  30. }
  31. }
  32. public RelayCommand AuthCommand
  33. {
  34. get
  35. {
  36. return _authcommand ??
  37. (_authcommand = new RelayCommand((x) =>
  38. {
  39. var authUser = Helper.GetContext().Employees.SingleOrDefault(user => user.Login == Login && user.Password == Password);
  40. if (authUser == null)
  41. {
  42. MessageBox.Show("Введите верный логин и пароль");
  43. return;
  44. }
  45. else
  46. {
  47. OUP Window1 = new OUP();
  48. Window1.Show();
  49. }
  50. }));
  51. }
  52. }
  53. }
  54. }