public async Task LinkAccount([FromBody] TelegramAccount account) { Authorization result = _bot.LinkAccount(account); if (result == Authorization.Valid) { string userID = User.Identity.Name; await using (MySqlConnection connection = new MySqlConnection(OTHubSettings.Instance.MariaDB.ConnectionString)) { await connection.ExecuteAsync("UPDATE Users SET TelegramUserID = @telegramUserID WHERE ID = @userID", new { userID = userID, telegramUserID = account.id }); int count = await connection.ExecuteScalarAsync<int>( @"SELECT COUNT(*) FROM telegramsettings WHERE userid = @userID", new { userID = userID }); if (count == 0) { await connection.ExecuteAsync( @"INSERT INTO telegramsettings (UserID, NotificationsEnabled, JobWonEnabled, HasReceivedMessageFromUser) VALUE (@userID, 1, 1, 0)", new { userID = userID }); } } } }