/// <summary> /// Заповнюємо список ролей /// </summary> private void FillRoles() { SecurityUserRolesLogic userRoles = new SecurityUserRolesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); List<SecurityRole> allRoles = roles.GetAll(); if (userId != null) { List<SecurityUserRole> userHasRoles = userRoles.GetAll(Convert.ToInt32(userId)); foreach (var role in allRoles) { Helpers.Item item = new Item(); item.ID = role.ID.ToString(); item.Name = role.Name; ((ListBox)RolesLB).DisplayMember = "Name"; ((ListBox)RolesLB).ValueMember = "ID"; SecurityUserRole userRole = userHasRoles.Where(a => a.RoleID == role.ID).Select(a => a).FirstOrDefault(); bool selected = false; if (userRole != null) { selected = true; } RolesLB.Items.Add(item, selected); } } }
/// <summary> /// Заповнюємо список ролей /// </summary> private void FillRoles() { SecurityUserRolesLogic userRoles = new SecurityUserRolesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); List <SecurityRole> allRoles = roles.GetAll(); if (userId != null) { List <SecurityUserRole> userHasRoles = userRoles.GetAll(Convert.ToInt32(userId)); foreach (var role in allRoles) { Helpers.Item item = new Item(); item.ID = role.ID.ToString(); item.Name = role.Name; ((ListBox)RolesLB).DisplayMember = "Name"; ((ListBox)RolesLB).ValueMember = "ID"; SecurityUserRole userRole = userHasRoles.Where(a => a.RoleID == role.ID).Select(a => a).FirstOrDefault(); bool selected = false; if (userRole != null) { selected = true; } RolesLB.Items.Add(item, selected); } } }
private void FillGrid() { ContextManager manager = new ContextManager(); SecurityRolesLogic sr = new SecurityRolesLogic(manager); RolesGV.DataSource = sr.GetAll(); manager.CloseContext(); }
public RoleActionsF() { InitializeComponent(); //створюэмо грід з можливістю групування GroupByGrid grid = new GroupByGrid(); ContextManager manager = new ContextManager(); SecurityActionsLogic actions = new Logic.Security.SecurityActionsLogic(manager); SecurityCategoriesLogic categories = new SecurityCategoriesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); ActionsGV.AutoGenerateColumns = false; RolesCB.DataSource = roles.GetAll(); CategoriesCB.DataSource = categories.GetAll(); manager.CloseContext(); }