Beispiel #1
0
 public async Task<string> AddSubreddit( Subreddit sub ) {
     sub.SubName = sub.SubName;
     using ( SqlConnection conn = new SqlConnection( connstring ) ) {
         string query = "insert into Subreddits (SubName,Active) values (@SubName,@Active)";
         await conn.ExecuteAsync( query, new { sub.SubName, sub.Active } );
         string result = "Success";
         return result;
     }
 }
Beispiel #2
0
 public async Task<bool> UpdateSubredditSettings( Subreddit sub ) {
     using ( SqlConnection conn = new SqlConnection( connstring ) ) {
         string query = "update ss " +
                         "set ss.AccessMask = @AccessMask " +
                         ", ss.PermBanID = @PermBanID " +
                         ", ss.TempBanID = @TempBanID " +
                         "from SubredditSettings ss inner join Subreddits s on s.SubRedditID = ss.SubRedditID " +
                         "where s.subname = @SubName";
         int rows = await conn.ExecuteAsync( query, new { sub.Settings.AccessMask, sub.Settings.PermBanID, sub.Settings.TempBanID, sub.SubName } );
         if ( rows <= 0 ) {
             string insert = "insert into SubredditSettings(SubRedditID,AccessMask,PermBanID,TempBanID) " +
                             "(select SubRedditID, @AccessMask ,@PermBanID,@TempBanID from Subreddits where SubName = @SubName)";
             conn.Execute( insert, new { sub.Settings.AccessMask, sub.Settings.PermBanID, sub.Settings.TempBanID, sub.SubName } );
         }
     }
     return true;
 }