Browse Source

added foolproofing

master
Nicolas Constant 2 years ago
parent
commit
d846756a7f
No known key found for this signature in database GPG Key ID: 1E9F677FB01A5688
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs

+ 7
- 1
src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs View File

@ -22,13 +22,15 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
public async Task CreateTwitterUserAsync(string acct, long lastTweetPostedId)
{
acct = acct.ToLowerInvariant();
using (var dbConnection = Connection)
{
dbConnection.Open();
await dbConnection.ExecuteAsync(
$"INSERT INTO {_settings.TwitterUserTableName} (acct,lastTweetPostedId,lastTweetSynchronizedForAllFollowersId) VALUES(@acct,@lastTweetPostedId,@lastTweetSynchronizedForAllFollowersId)",
new { acct = acct, lastTweetPostedId = lastTweetPostedId, lastTweetSynchronizedForAllFollowersId = lastTweetPostedId });
new { acct, lastTweetPostedId, lastTweetSynchronizedForAllFollowersId = lastTweetPostedId });
}
}
@ -36,6 +38,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
{
var query = $"SELECT * FROM {_settings.TwitterUserTableName} WHERE acct = @acct";
acct = acct.ToLowerInvariant();
using (var dbConnection = Connection)
{
dbConnection.Open();
@ -78,6 +82,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
{
if (acct == default) throw new ArgumentException("acct");
acct = acct.ToLowerInvariant();
var query = $"DELETE FROM {_settings.TwitterUserTableName} WHERE acct = @acct";
using (var dbConnection = Connection)


Loading…
Cancel
Save