123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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<User> _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<User> 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<User>(loferlcontext.Users);
- _user = new User();
- }
- }
- }
|