public IList <User> GetUsersByRoleId(int roleId) { List <User> users = new List <User>(); DataTable userTable = manager.GetUsersByRoleId(roleId); foreach (DataRow row in userTable.Rows) { User user = new User(); user.UserId = Convert.ToInt32(row["UserId"]); user.UserName = row["UserName"] == null ? "" : row["UserName"].ToString(); user.EmpName = row["EmployeeName"] == null ? "" : row["EmployeeName"].ToString(); user.Password = row["Password"] == null ? "" : row["Password"].ToString(); user.Mobile = row["Mobile"] == null ? "" : row["Mobile"].ToString(); user.EmployeeId = row["EmployeeId"] == null ? "" : row["EmployeeId"].ToString(); if (user.UserId == UserAdminId) { user.IsAdmin = true; } user.IsActive = row["IsActive"] == null ? false : (row["IsActive"].ToString() == "0" ? false : true); //IList<int> roleIds = manager.GetAllRolesIdByUserID(user.UserId); //foreach (int roleID in roleIds) //{ // Role role = Roles.DefaultRoles.GetRoleByRoleId(roleID); // user.AddRole(role); //} //DataTable userRolePermissions = manager.GetAllRolePermissionsByUserId(user.UserId); //foreach (DataRow row1 in userRolePermissions.Rows) //{ // int roleId1 = Convert.ToInt32(row1["roleId"]); // Role role = Roles.DefaultRoles.GetRoleByRoleId(roleId1); // int permissionId = Convert.ToInt32(row1["permissionId"]); // Permission permission = Permissions.GetPermissionById(permissionId); // user.AddPermission(permission, role); //} users.Add(user); } return(users); }