First Commit

This commit is contained in:
Jorge Luis caudillo esparza
2026-05-09 16:36:57 -07:00
parent 96ad4c0d3e
commit d0c284d9c0
131 changed files with 4009 additions and 0 deletions

View File

@@ -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();
}
}