public Task DeleteAsync(Comment comment) {
     return Task.Run(async () => {
         Comment c = await GetAsync(comment.Id);
         if (c != null) {
             InMemoryComments.Remove(c);
         }
     });
 }
Example #2
0
 public async Task CreateAsync(Comment comment) {
     using (SqlConnection connection = Connection) {
         const string query =
             "INSERT INTO Comments (CountdownId, Text, CreatedById, CreatedOn) " +
             "OUTPUT INSERTED.Id " +
             "VALUES (@CountdownId, @Text, @CreatedById, @CreatedOn)";
         comment.Id = (await connection.QueryAsync<long>(query, comment)).Single();
     }
 }
 public Task CreateAsync(Comment comment) {
     return Task.Run(() => InMemoryComments.Add(comment));
 }
Example #4
0
 public async Task DeleteAsync(Comment comment) {
     using (SqlConnection connection = Connection) {
         await connection.ExecuteAsync("DELETE FROM Comments WHERE Id = @Id", comment);
     }
 }