2024-12-10 13:55:01 +05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Persistence.Client.Clients.Base;
|
|
|
|
|
using Persistence.Client.Clients.Interfaces;
|
|
|
|
|
using Persistence.Models;
|
|
|
|
|
using Persistence.Models.Requests;
|
|
|
|
|
|
|
|
|
|
namespace Persistence.Client.Clients;
|
|
|
|
|
public class ChangeLogClient : BaseClient, IChangeLogClient
|
|
|
|
|
{
|
|
|
|
|
private readonly Interfaces.Refit.IRefitChangeLogClient refitChangeLogClient;
|
|
|
|
|
|
|
|
|
|
public ChangeLogClient(Interfaces.Refit.IRefitChangeLogClient refitChangeLogClient, ILogger<ChangeLogClient> logger) : base(logger)
|
|
|
|
|
{
|
|
|
|
|
this.refitChangeLogClient = refitChangeLogClient;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<int> ClearAndAddRange(int idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
2024-12-10 13:55:01 +05:00
|
|
|
|
{
|
|
|
|
|
var result = await ExecuteGetResponse<int>(
|
|
|
|
|
async () => await refitChangeLogClient.ClearAndAddRange(idDiscriminator, dtos, token), token);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<PaginationContainer<DataWithWellDepthAndSectionDto>> GetByDate(int idDiscriminator, DateTimeOffset moment,
|
2024-12-10 13:55:01 +05:00
|
|
|
|
SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
var result = await ExecuteGetResponse<PaginationContainer<DataWithWellDepthAndSectionDto>>(
|
|
|
|
|
async () => await refitChangeLogClient.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token), token);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<IEnumerable<ChangeLogDto>> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
2024-12-10 13:55:01 +05:00
|
|
|
|
{
|
|
|
|
|
var result = await ExecuteGetResponse<IEnumerable<ChangeLogDto>>(
|
|
|
|
|
async () => await refitChangeLogClient.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token), token);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<int> Add(int idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token)
|
2024-12-10 13:55:01 +05:00
|
|
|
|
{
|
|
|
|
|
var result = await ExecutePostResponse(
|
|
|
|
|
async () => await refitChangeLogClient.Add(idDiscriminator, dto, token), token);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<int> AddRange(int idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
2024-12-10 13:55:01 +05:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 11:25:57 +05:00
|
|
|
|
public async Task<DatesRangeDto?> GetDatesRange(int idDiscriminator, CancellationToken token)
|
2024-12-10 13:55:01 +05:00
|
|
|
|
{
|
|
|
|
|
var result = await ExecuteGetResponse<DatesRangeDto?>(
|
|
|
|
|
async () => await refitChangeLogClient.GetDatesRange(idDiscriminator, token), token);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
refitChangeLogClient.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|