66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Persistence.Client.Clients.Base;
|
|
using Persistence.Client.Clients.Interfaces;
|
|
using Persistence.Client.Clients.Interfaces.Refit;
|
|
using Persistence.Models;
|
|
|
|
namespace Persistence.Client.Clients;
|
|
|
|
public class TechMessagesClient : BaseClient, ITechMessagesClient
|
|
{
|
|
private readonly IRefitTechMessagesClient refitTechMessagesClient;
|
|
|
|
public TechMessagesClient(IRefitTechMessagesClient refitTechMessagesClient, ILogger logger) : base(logger)
|
|
{
|
|
this.refitTechMessagesClient = refitTechMessagesClient;
|
|
}
|
|
|
|
public async Task<PaginationContainer<TechMessageDto>> GetPage(RequestDto request, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse<PaginationContainer<TechMessageDto>>(
|
|
async () => await refitTechMessagesClient.GetPage(request, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<int> AddRange(IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
|
{
|
|
var result = await ExecutePostResponse(
|
|
async () => await refitTechMessagesClient.AddRange(dtos, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<string>> GetSystems(CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse<IEnumerable<string>>(
|
|
async () => await refitTechMessagesClient.GetSystems(token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<DatesRangeDto> GetDatesRangeAsync(CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse<DatesRangeDto>(
|
|
async () => await refitTechMessagesClient.GetDatesRangeAsync(token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<TechMessageDto>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse<IEnumerable<TechMessageDto>>(
|
|
async () => await refitTechMessagesClient.GetPart(dateBegin, take, token), token);
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<IEnumerable<MessagesStatisticDto>> GetStatistics(string autoDrillingSystem, int categoryId, CancellationToken token)
|
|
{
|
|
var result = await ExecuteGetResponse<IEnumerable<MessagesStatisticDto>>(
|
|
async () => await refitTechMessagesClient.GetStatistics(autoDrillingSystem, categoryId, token), token);
|
|
|
|
return result;
|
|
}
|
|
}
|