using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using Rkis29.ViewModel; using Rkis29.Windows; namespace Rkis29.Command { public class RegistrationCod: BaseViewModel { private ObservableCollection _users; private User _user; private RelayCommand _registration; private RelayCommand _return; public RelayCommand Return { get { return _return ?? (_return = new RelayCommand(x => { MainWindow Window = new MainWindow(); Window.Show(); foreach (var win in App.Current.Windows) { if (win is Registration mainWindow) { mainWindow.Close(); } } } )); } } public RelayCommand Registration { get { return _registration ?? (_registration = new RelayCommand((x) => { if ((User.FirstName != null) && (User.Name != null) && (User.LastName != null) && (User.PhonNum != null) && (User.Login != null) && (User.Password != null)) { loferlContext loferlcontext = new loferlContext(); User user = User; loferlcontext.Users.Add(user); loferlcontext.SaveChanges(); user = null; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); foreach (var window in App.Current.Windows) { if (window is Registration registration) { registration.Close(); } } } else { MessageBox.Show("You are not write to the box "); } })); } } public ObservableCollection Users { get => _users; set { _users = value; OnPropertyChanged(); } } public User User { get => _user; set { _user = value; OnPropertyChanged(); } } public RegistrationCod() { loferlContext loferlcontext = new loferlContext(); _users = new ObservableCollection(loferlcontext.Users); _user = new User(); } } }