VMAutor.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Rkis29.Model;
  2. using Rkis29.View;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. namespace Rkis29.ViewModel
  13. {
  14. public class VMAutor : INotifyPropertyChanged
  15. {
  16. public event PropertyChangedEventHandler PropertyChanged;
  17. public void OnPropertyChanged([CallerMemberName] string prop = "")
  18. {
  19. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
  20. }
  21. public string Login { get; set; }
  22. private RelayCommand _autho_ready;
  23. public RelayCommand Autho_ready
  24. {
  25. get
  26. {
  27. return _autho_ready ?? new RelayCommand(obj =>
  28. {
  29. var value = (object[])obj;//создание массива значений объекта окна
  30. var password = (PasswordBox)value[0];
  31. var mainWnd = (Window)value[1];
  32. var User = ModelPublic.GetContext().Person.FirstOrDefault(f => f.Logins == Login && f.Passwords == password.Password); //свойство для поиска пользователя
  33. if (User != null)
  34. {
  35. Users.Id = User.Id;
  36. Registration registration = new Registration();
  37. registration.Show();
  38. mainWnd.Close();
  39. }
  40. else
  41. {
  42. MessageBox.Show("Неверные данные");
  43. }
  44. });
  45. }
  46. }
  47. public RelayCommand _registrWND;
  48. public RelayCommand RegistrWND
  49. {
  50. get
  51. {
  52. return _registrWND ?? new RelayCommand(obj =>
  53. {
  54. Profile profile = new Profile();
  55. profile.Show();
  56. Window window = (Window)obj;
  57. window.Close();
  58. });
  59. }
  60. }
  61. }
  62. }