6593acbc20
Some checks failed
Unit tests / test (push) Failing after 1m1s
Работает пока только для ChangeLog
106 lines
3.4 KiB
C#
106 lines
3.4 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using DD.Persistence.Client.Clients.Base;
|
|
using DD.Persistence.Client.Clients.Interfaces;
|
|
using DD.Persistence.Models;
|
|
using DD.Persistence.Models.Requests;
|
|
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
|
|
namespace DD.Persistence.Client.Clients;
|
|
public class ChangeLogClient : BaseClient, IChangeLogClient
|
|
{
|
|
private readonly IRefitChangeLogClient refitChangeLogClient;
|
|
|
|
public ChangeLogClient(IRefitClientFactory<IRefitChangeLogClient> refitClientFactory, ILogger<ChangeLogClient> logger) : base(logger)
|
|
{
|
|
this.refitChangeLogClient = refitClientFactory.Create();
|
|
}
|
|
|
|
public async Task<int> ClearAndAddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitChangeLogClient.ClearAndAddRange(idDiscriminator, dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<PaginationContainer<DataWithWellDepthAndSectionDto>> GetByDate(Guid idDiscriminator, DateTimeOffset moment,
|
|
SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitChangeLogClient.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<ChangeLogDto>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitChangeLogClient.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token), token);
|
|
|
|
return result!;
|
|
}
|
|
|
|
public async Task<int> Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.Add(idDiscriminator, dto, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> AddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.AddRange(idDiscriminator, dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> Update(DataWithWellDepthAndSectionDto dto, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.Update(dto, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> UpdateRange(IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.UpdateRange(dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> Delete(Guid id, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.Delete(id, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> DeleteRange(IEnumerable<Guid> ids, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitChangeLogClient.DeleteRange(ids, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<DatesRangeDto?> GetDatesRange(Guid idDiscriminator, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse(
|
|
async () => await refitChangeLogClient.GetDatesRange(idDiscriminator, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
refitChangeLogClient.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|