private void PopulatePermissions(params string[] selectedpermissions) { var permissions = AssignableToRolePermissions.GetAsSelectListItems(); if (selectedpermissions != null) { permissions.ForEach( a => a.Selected = selectedpermissions.Any(s => s == a.Value)); } ViewBag.Permissions = permissions; }
public void FillForEdit(EditRoleViewModel viewModel) { var permissions = AssignableToRolePermissions.GetAsSelectListItems(); var selectListItems = permissions as IList <SelectListItem> ?? permissions.ToList(); if (viewModel.PermissionNames != null) { selectListItems.ToList().ForEach( a => a.Selected = viewModel.PermissionNames.Any(s => s == a.Value)); } viewModel.Permissions = selectListItems; }