64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using DD.Persistence.Client.Clients.Base;
|
|
using DD.Persistence.Client.Clients.Interfaces;
|
|
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
using DD.Persistence.Models;
|
|
|
|
namespace DD.Persistence.Client.Clients;
|
|
public class TimestampedSetClient : BaseClient, ITimestampedSetClient
|
|
{
|
|
private readonly IRefitTimestampedSetClient refitTimestampedSetClient;
|
|
|
|
public TimestampedSetClient(IRefitClientFactory<IRefitTimestampedSetClient> refitTimestampedSetClientFactory, ILogger<TimestampedSetClient> logger) : base(logger)
|
|
{
|
|
this.refitTimestampedSetClient = refitTimestampedSetClientFactory.Create();
|
|
}
|
|
|
|
public async Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitTimestampedSetClient.AddRange(idDiscriminator, sets, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<TimestampedSetDto>> Get(Guid idDiscriminator, DateTimeOffset? geTimestamp, IEnumerable<string>? columnNames, int skip, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.Get(idDiscriminator, geTimestamp, columnNames, skip, take, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<IEnumerable<TimestampedSetDto>> GetLast(Guid idDiscriminator, IEnumerable<string>? columnNames, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetLast(idDiscriminator, columnNames, take, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<int> Count(Guid idDiscriminator, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.Count(idDiscriminator, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<DatesRangeDto?> GetDatesRange(Guid idDiscriminator, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitTimestampedSetClient.GetDatesRange(idDiscriminator, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
refitTimestampedSetClient.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|