First Commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System.Data;
|
||||
using ADS.Apis.Gps.Application.Units;
|
||||
using ADS.Helpers.Data;
|
||||
using ADS.Helpers.Data.Abstractions;
|
||||
using Dapper;
|
||||
|
||||
namespace ADS.Apis.Gps.Infrastructure.Units;
|
||||
|
||||
public sealed class UnitLocationQueryService : IUnitLocationQueryService
|
||||
{
|
||||
private readonly ITenantDbConnectionFactory _connectionFactory;
|
||||
|
||||
public UnitLocationQueryService(ITenantDbConnectionFactory connectionFactory)
|
||||
{
|
||||
_connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
public async Task<UnitLastLocationResponse?> GetLastLocationByNoEconomicoAsync(
|
||||
int cveUsuario,
|
||||
string noEconomico,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
using var connection = _connectionFactory.Create();
|
||||
|
||||
var command = new CommandDefinition(
|
||||
commandText: "dbo.PA_GPS_DispositovoUbicacionByNoEconomicoGet",
|
||||
parameters: new
|
||||
{
|
||||
CveUsuario = cveUsuario,
|
||||
NoEconomico = noEconomico
|
||||
},
|
||||
commandType: CommandType.StoredProcedure,
|
||||
cancellationToken: ct
|
||||
);
|
||||
|
||||
return await connection.QueryFirstOrDefaultAsync<UnitLastLocationResponse>(command);
|
||||
}
|
||||
public async Task<IReadOnlyList<UnitClientLocationResponse>> GetLocationsByClientAsync(
|
||||
int cveUsuario,
|
||||
int cveCliente,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
using var connection = _connectionFactory.Create();
|
||||
|
||||
var command = new CommandDefinition(
|
||||
commandText: "dbo.PA_GPS_DispositovoUbicacionPorClienteGet",
|
||||
parameters: new
|
||||
{
|
||||
CveUsuario = cveUsuario,
|
||||
CveCliente = cveCliente
|
||||
},
|
||||
commandType: CommandType.StoredProcedure,
|
||||
cancellationToken: ct
|
||||
);
|
||||
|
||||
var result = await connection.QueryAsync<UnitClientLocationResponse>(command);
|
||||
|
||||
return result.AsList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user