123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using Rkis29;
- using Rkis29.ViewModel;
- using Rkis29.Windows;
- namespace Rkis29.Command
- {
-
- public class MainWindowCod : BaseViewModel
- {
- private User _user = new User();
- private ObservableCollection<User> _users;
- private RelayCommand _NextWindow;
- private RelayCommand _RegistrationWindow;
- public RelayCommand NextWindow
- {
- get
- {
- return _NextWindow ??
- (_NextWindow = new RelayCommand(x =>
- {
- PasswordBox pb = (PasswordBox)x;
- using (loferlContext db = new loferlContext())
- {
- User user_ = db.Users.FirstOrDefault(el => el.Login == User.Login && el.Password == pb.Password);
- if (user_ != null)
- {
- User.AutoUser = user_;
- YourProfile Window = new YourProfile();
- Window.Show();
- foreach (var win in App.Current.Windows)
- {
- if (win is MainWindow mainWindow)
- {
- mainWindow.Close();
- }
- }
- }
- }
- }));
- }
- }
- public RelayCommand RegistrationWindow
- {
- get
- {
- return _RegistrationWindow ?? (_RegistrationWindow = new RelayCommand(x =>
- {
- Registration Window = new Registration();
- Window.Show();
- foreach (var win in App.Current.Windows)
- {
- if (win is MainWindow mainWindow)
- {
- mainWindow.Close();
- }
- }
- }
- ));
- }
- }
- public User User
- {
- get => _user;
- set
- {
- _user = value;
- OnPropertyChanged();
- }
- }
- public ObservableCollection<User> Users
- {
- get => _users;
- set
- {
- _users = value;
- OnPropertyChanged();
- }
- }
- public MainWindowCod()
- {
- loferlContext loferlcontext = new loferlContext();
- Users = new ObservableCollection<User>(loferlcontext.Users);
- User = new User();
- }
- }
- }
|