Esempio n. 1
0
        public IList <User> GetUsersByName(string userName)
        {
            List <User> users     = new List <User>();
            DataTable   userTable = manager.GetUsersByName(userName);

            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 roleId = Convert.ToInt32(row1["roleId"]);
                //    Role role = Roles.DefaultRoles.GetRoleByRoleId(roleId);
                //    int permissionId = Convert.ToInt32(row1["permissionId"]);
                //    Permission permission = Permissions.GetPermissionById(permissionId);
                //    user.AddPermission(permission, role);
                //}
                users.Add(user);
            }
            return(users);
        }