private void ExecuteAddUserToActualGroupCommand(object obj) { try { if (ActualGroup == null) { return; } AddUserToGroupDialog dlg = new AddUserToGroupDialog(); dlg.Owner = Application.Current.MainWindow; dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner; dlg.Facade = this; if (dlg.ShowDialog() == true) { foreach (UserInfo ui in dlg.SelectedUserInfos) { var x = from gi in ui.Groups where gi.Group.Name == ActualGroup.Name select gi; GroupMembershipInfo groupInfo = x.FirstOrDefault <GroupMembershipInfo>(); if (groupInfo == null) { return; } groupInfo.IsMember = true; SecurityFramework.UpdateUser(groupInfo.User); Group g = ActualGroup; ActualGroup = null; _Users = null; //_Groups = null; //ActualUser = null; //NotifyPropertyChanged("Groups"); NotifyPropertyChanged("Users"); NotifyPropertyChanged("GroupInfos"); ActualGroup = g; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } RaiseCanExecuteChanged(); }
private void ExecuteAddUserToActualGroupCommand(object obj) { try { if (ActualGroup == null) return; AddUserToGroupDialog dlg = new AddUserToGroupDialog(); dlg.Owner = Application.Current.MainWindow; dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner; dlg.Facade = this; if (dlg.ShowDialog() == true) { foreach (UserInfo ui in dlg.SelectedUserInfos) { var x = from gi in ui.Groups where gi.Group.Name == ActualGroup.Name select gi; GroupMembershipInfo groupInfo = x.FirstOrDefault<GroupMembershipInfo>(); if (groupInfo == null) return; groupInfo.IsMember = true; SecurityFramework.UpdateUser(groupInfo.User); Group g = ActualGroup; ActualGroup = null; _Users = null; //_Groups = null; //ActualUser = null; //NotifyPropertyChanged("Groups"); NotifyPropertyChanged("Users"); NotifyPropertyChanged("GroupInfos"); ActualGroup = g; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } RaiseCanExecuteChanged(); }