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 _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 Users { get => _users; set { _users = value; OnPropertyChanged(); } } public MainWindowCod() { loferlContext loferlcontext = new loferlContext(); Users = new ObservableCollection(loferlcontext.Users); User = new User(); } } }