/// <summary> /// 查询角色List /// </summary> /// <param name="total">总数</param> /// <param name="search">查询条件</param> /// <returns>角色列表</returns> public List <RoleViewModel> GetRoleViewModel(SearchBaseModel search, out int total) { RoleBll roleBll = new RoleBll(); List <Role> roleList = roleBll.GetPageRoles(search.RoleName, search.PageStart, search.PageSize, search.SortCol, search.SortDir, out total); List <RoleViewModel> roleView = new List <RoleViewModel>(); UserBll uBll = new UserBll(); //将数据库查出的List<Role>转为List<RoleViewModel>视图模型 foreach (var role in roleList) { RoleViewModel roleViewModel = new RoleViewModel { Id = role.Id, RoleName = role.RoleName, Code = role.Code, LastChangeTime = role.LastChangeTime.ToString(CultureInfo.InvariantCulture), LastChangeUser = uBll.GetUserById(role.LastChangeUser).UserName, Description = role.Description }; roleView.Add(roleViewModel); } return(roleView); }