public static List <ModuleAction> GetModuleActionForUser(string username) { var repoUser = new EFUserRepository(); var result = new List <ModuleAction>(); var filter = GetFilterInfo(username); var user = repoUser.Find(null, filter); var roleIndex = user.Roles.GetEnumerator(); while (roleIndex.MoveNext()) { var role = roleIndex.Current; var modulesInRoles = role.ModulesInRoles; var moduleInRoleIndex = modulesInRoles.GetEnumerator(); while (moduleInRoleIndex.MoveNext()) { var modulesInRole = moduleInRoleIndex.Current; var moduleName = modulesInRole.Module.ModuleName; result.AddRange(modulesInRole.Actions.Select(p => new ModuleAction { ModuleName = moduleName, ActionName = p.ActionName })); } } return(result); }