public Task DeleteAsync(Comment comment) { return Task.Run(async () => { Comment c = await GetAsync(comment.Id); if (c != null) { InMemoryComments.Remove(c); } }); }
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)); }
public async Task DeleteAsync(Comment comment) { using (SqlConnection connection = Connection) { await connection.ExecuteAsync("DELETE FROM Comments WHERE Id = @Id", comment); } }