Example #1
0
 public UserWindow(User user)
 {
     InitializeComponent();
     WindowStartupLocation = WindowStartupLocation.CenterOwner;
     ucSaveAndClose.CloseButtonClick = (sender, args) => Close();
     ucSaveAndClose.SaveAndCloseButtonClick = SaveAndCloseButtonClick;
     _user = user;
 }
Example #2
0
 public void DeleteUser(User user)
 {
     var existingUser = _context.Users.FirstOrDefault(usr => usr.Id == user.Id);
     if (existingUser == null)
     {
         return;
     }
     _context.Users.Remove(existingUser);
 }
Example #3
0
 public void UpdateUser(User user)
 {
     var existingUser = _context.Users.FirstOrDefault(usr => usr.Id == user.Id);
     if (existingUser == null)
     {
         return;
     }
     _context.Entry(existingUser).CurrentValues.SetValues(user);
     _context.Entry(existingUser).State = EntityState.Modified;;
 }
Example #4
0
 private bool IsAdminValues()
 {
     if (!txtLogin.Text.Equals("Admin") || !txtPassword.Text.Equals("Admin"))
     {
         return false;
     }
     CurrentUser = new User
     {
         Login = "******"
     };
     return true;
 }
Example #5
0
 public void AddUser(User user)
 {
     _context.Users.Add(user);
 }
Example #6
0
 private void UserWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     if (_user == null)
     {
         _user = new User();
     }
     else
     {
         SetUsersValues();
     }
 }