public async Task <SwitchUser> GetSwitchFC(ulong userId) { SwitchUser temp = null; using (SQLiteConnection db = new SQLiteConnection(FCConnectionString)) { await db.OpenAsync(); using (var cmd = new SQLiteCommand("select * from switchfcs where UserId = @1;", db)) { cmd.Parameters.AddWithValue("@1", userId); using (var reader = await cmd.ExecuteReaderAsync()) { if (await reader.ReadAsync()) { temp = new SwitchUser() { UserId = Convert.ToUInt64((string)reader["UserId"]), FriendCode = (reader["FriendCode"] == DBNull.Value) ? 0 : Convert.ToUInt64((string)reader["FriendCode"]), SwitchNickname = reader["SwitchNickname"] == DBNull.Value ? null : (string)reader["SwitchNickname"], MessageId = (reader["MessageId"] == DBNull.Value) ? 0 : Convert.ToUInt64((string)reader["MessageId"]) }; } } } db.Close(); } return(temp); }
public async Task <SwitchUser> AddFriendCode(ulong userId, ulong friendCode, ulong messageId, string switchNickname = null) { SwitchUser temp = new SwitchUser() { UserId = userId, FriendCode = friendCode, SwitchNickname = switchNickname, MessageId = messageId }; await BulkAddFriendCodes(new List <SwitchUser> { temp }); return(temp); }