public void SelectIndexChanged(GroupsModel group) { if (group != null) { GroupRolesSource.Clear(); var roles = GroupRoles.Where(x => x.GrolrGIdFk == group.GId); foreach (var item in roles) { var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault(); if (role != null) { GroupRolesSource.Add(role.FillRoles(item)); } } } }
protected void GroupItemChanging(GroupsModel newValue) { if (newValue != null) { GroupRolesSource.Clear(); var roles = GroupRoles.Where(x => x.GrolrGIdFk == newValue.GId); foreach (var item in roles) { var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault(); if (role != null) { GroupRolesSource.Add(role.FillRoles(item)); } } } }
public void Edit() { if (SelectedDataItem != null) { var item = SelectedDataItem; for (int i = 0; i < Roles.Count; i++) { var role = GroupRolesSource.Where(x => x.RoleId == Roles[i].RoleId).FirstOrDefault(); if (role != null) { var groupRoles = GroupRoles.Where(x => x.GrolrRoleIdFk == Roles[i].RoleId && x.GrolrGIdFk == item.GId).FirstOrDefault(); Roles[i].IsChecked = true; Roles[i].GroleAdd = groupRoles.GroleAdd; Roles[i].GroleEdit = groupRoles.GroleEdit; Roles[i].GroleDelete = groupRoles.GroleDelete; Roles[i].GroleExport = groupRoles.GroleExport; Roles[i].GrolePrint = groupRoles.GrolePrint; Roles[i].GroleView = groupRoles.GroleView; } else { Roles[i].IsChecked = false; Roles[i].GroleAdd = false.ToIntState(); Roles[i].GroleEdit = false.ToIntState(); Roles[i].GroleDelete = false.ToIntState(); Roles[i].GroleExport = false.ToIntState(); Roles[i].GrolePrint = false.ToIntState(); Roles[i].GroleView = false.ToIntState(); } } VGroupsEdit edit = new VGroupsEdit(Roles, item); if (edit.ShowDialog() == true) { var dataContext = edit.DataContext as VMGroupsEdit; DataGridSource.Remove(SelectedDataItem); DataGridSource.Add(dataContext.EditGroup); GroupRoles.RemoveAll(x => x.GrolrGIdFk == item.GId); GroupRoles.AddRange(dataContext.DataGridSource.Where(x => x.RoleSelected()).Select(x => x.ToGroupRoles(item.GId))); } GroupRolesSource.Clear(); } }
protected void GroupItemChanging(GroupsModel newValue) { IsInProgress = true; new Thread(() => { }) { IsBackground = true }.Start(); if (newValue != null) { GroupRolesSource.Clear(); var roles = GroupRoles.Where(x => x.GrolrGIdFk == newValue.GId); foreach (var item in roles) { var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault(); if (role != null) { GroupRolesSource.Add(role.FillRoles(item)); } } } }