private void ExcuteAddRoleViewCommand() { try { SelectedRoles.Add(SelectedRoleToAdd); FilteredRoles = new ObservableCollection <RoleDTO>(Roles.Except(SelectedRoles)); } catch { MessageBox.Show("Can't Save Role"); } }
private void OnAddUserRoleButtonClick(object sender, RoutedEventArgs e) { var win = new WindowSelectRole(); win.Closed += (o, ea) => { if (win.DialogResult.HasValue && win.DialogResult.Value) { userInfoChanged = true; if (SelectedRoles == null) { SelectedRoles = new List <UserRoleRel>(); } foreach (var c in win.SelectedRole) { if (SelectedRoles.Any(uo => uo.RoleId == c.RoleId)) { continue; } SelectedRoles.Add(new UserRoleRel { Id = 0, UserId = AuthenticateStatus.CurrentUser.UserId, RoleId = c.RoleId, Role = c, StartTime = DateTime.Now.Date, ExpireTime = DateTime.Now.Date.AddYears(10), CreatedBy = AuthenticateStatus.CurrentUser.UserId, CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now, LastUpdatedBy = AuthenticateStatus.CurrentUser.UserId, }); } UserRolesList.ItemsSource = null; UserRolesList.ItemsSource = SelectedRoles; } }; win.Show(); }