mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
34 lines
1 KiB
C#
34 lines
1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Plugins.Test.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace BTCPayServer.Plugins.Test.Services
|
|
{
|
|
public class TestPluginService
|
|
{
|
|
private readonly TestPluginDbContextFactory _testPluginDbContextFactory;
|
|
|
|
public TestPluginService(TestPluginDbContextFactory testPluginDbContextFactory)
|
|
{
|
|
_testPluginDbContextFactory = testPluginDbContextFactory;
|
|
}
|
|
|
|
public async Task AddTestDataRecord()
|
|
{
|
|
await using var context = _testPluginDbContextFactory.CreateContext();
|
|
|
|
await context.TestPluginRecords.AddAsync(new TestPluginData() { Timestamp = DateTimeOffset.UtcNow });
|
|
await context.SaveChangesAsync();
|
|
}
|
|
|
|
|
|
public async Task<List<TestPluginData>> Get()
|
|
{
|
|
await using var context = _testPluginDbContextFactory.CreateContext();
|
|
|
|
return await context.TestPluginRecords.ToListAsync();
|
|
}
|
|
}
|
|
}
|