public static User GetUserByUsername(string Username) { UserTableAdapter localAdapter = new UserTableAdapter(); if (string.IsNullOrEmpty(Username)) { return(null); } User theUser = null; try { UserDS.UserDataTable table = localAdapter.GetUserByUsername(Username); if (table != null && table.Rows.Count > 0) { UserDS.UserRow row = table[0]; theUser = FillUserRecord(row); } } catch (Exception q) { log.Error("An error was ocurred while geting user data", q); } return(theUser); }
private static User FillUserRecord(UserDS.UserRow row) { User theNewRecord = new User( row.userId, row.fullname, row.IscellphoneNull() ? "" : row.cellphone, row.IsaddressNull() ? "" : row.address, row.IsphonenumberNull() ? "" : row.phonenumber, row.IsphoneareaNull() ? 0 : row.phonearea, row.IsphonecodeNull() ? 0 : row.phonecode, row.username, row.IsemailNull() ? "" : row.email); return(theNewRecord); }