Skip to content

Commit

Permalink
style: code cleanup on repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresRamos committed Aug 6, 2023
1 parent ed2a4f6 commit 0d91302
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
10 changes: 6 additions & 4 deletions src/Api.Sync.Infrastructure/Api.Sync.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Common\**" />
<EmbeddedResource Remove="Common\**" />
<None Remove="Common\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ARSoftware.Contpaqi.Comercial.Sql" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
Expand All @@ -19,8 +25,4 @@
<Using Include="ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Models" />
</ItemGroup>

<ItemGroup>
<Folder Include="Common\Mappings\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ private async Task CargarDatosRelacionadosAsync(Agente agente, AgenteDto agenteS
CancellationToken cancellationToken)
{
if (loadRelatedDataOptions.CargarDatosExtra)
{
agente.DatosExtra = (await _context.admAgentes.FirstAsync(m => m.CIDAGENTE == agenteSql.CIDAGENTE, cancellationToken))
.ToDatosDictionary<admAgentes>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ private async Task CargarDatosRelacionadosAsync(Almacen almacen, AlmacenDto alma
CancellationToken cancellationToken)
{
if (loadRelatedDataOptions.CargarDatosExtra)
{
almacen.DatosExtra = (await _context.admAlmacenes.FirstAsync(m => m.CIDALMACEN == almacenSql.CIDALMACEN, cancellationToken))
.ToDatosDictionary<admAlmacenes>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Api.Core.Domain.Requests;
using Api.Sync.Core.Application.ContpaqiComercial.Interfaces;
using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Dtos;
using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums;
using ARSoftware.Contpaqi.Comercial.Sdk.Extras.Extensions;
using ARSoftware.Contpaqi.Comercial.Sql.Contexts;
using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa;
Expand Down Expand Up @@ -91,10 +92,10 @@ public async Task<IEnumerable<ClienteProveedor>> BuscarPorRequestModel(BuscarCli

public async Task<bool> ExisteDireccionFiscalDelClienteAsync(string codigo, CancellationToken cancellationToken)
{
// Todo: cambiar d.CTIPODIRECCION == (int)TipoDireccion.Fiscal y d.CTIPOCATALOGO == (int)TipoCatalogoDireccion.Clientes
admClientes cliente = await _context.admClientes.FirstAsync(c => c.CCODIGOCLIENTE == codigo, cancellationToken);
return await _context.admDomicilios.AnyAsync(
d => d.CIDCATALOGO == cliente.CIDCLIENTEPROVEEDOR && d.CTIPODIRECCION == 0 && d.CTIPOCATALOGO == 1, cancellationToken);
d => d.CIDCATALOGO == cliente.CIDCLIENTEPROVEEDOR && d.CTIPODIRECCION == (int)TipoDireccion.Fiscal &&
d.CTIPOCATALOGO == (int)TipoCatalogoDireccion.Clientes, cancellationToken);
}

private async Task CargarDatosRelacionadosAsync(ClienteProveedor cliente, ClienteProveedorDto clienteSql,
Expand All @@ -111,7 +112,8 @@ private async Task CargarDatosRelacionadosAsync(ClienteProveedor cliente, Client
private async Task<Direccion?> BuscarDireccionFiscalAsync(int clienteId, CancellationToken cancellationToken)
{
DireccionDto? admDomicilio = await _context.admDomicilios
.Where(d => d.CIDCATALOGO == clienteId && d.CTIPODIRECCION == 0 && d.CTIPOCATALOGO == 1)
.Where(d => d.CIDCATALOGO == clienteId && d.CTIPODIRECCION == (int)TipoDireccion.Fiscal &&
d.CTIPOCATALOGO == (int)TipoCatalogoDireccion.Clientes)
.ProjectTo<DireccionDto>(_mapper.ConfigurationProvider)
.FirstOrDefaultAsync(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ private async Task CargarDatosRelacionadosAsync(ConceptoDocumento concepto, Conc
ILoadRelatedDataOptions loadRelatedDataOptions, CancellationToken cancellationToken)
{
if (loadRelatedDataOptions.CargarDatosExtra)
{
concepto.DatosExtra =
(await _context.admConceptos.FirstAsync(c => c.CIDCONCEPTODOCUMENTO == conceptoSql.CIDCONCEPTODOCUMENTO, cancellationToken))
.ToDatosDictionary<admConceptos>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ private async Task CargarDatosRelacionadosAsync(FolioDigital folioDigital, Folio
ILoadRelatedDataOptions loadRelatedDataOptions, CancellationToken cancellationToken)
{
if (loadRelatedDataOptions.CargarDatosExtra)
{
folioDigital.DatosExtra =
(await _context.admFoliosDigitales.FirstAsync(m => m.CIDFOLDIG == folioDigitalSql.CIDFOLDIG, cancellationToken))
.ToDatosDictionary<admFoliosDigitales>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ private async Task CargarDatosRelacionadosAsync(Movimiento movimiento, Movimient
movimiento.Producto =
await _productoRepository.BuscarPorIdAsync(movimientoSql.CIDPRODUCTO, loadRelatedDataOptions, cancellationToken) ??
new Producto();
movimiento.Almacen =
await _almacenRepository.BuscarPorIdAsync(movimientoSql.CIDALMACEN, loadRelatedDataOptions, cancellationToken) ?? new Almacen();

movimiento.Almacen = await _almacenRepository.BuscarPorIdAsync(movimientoSql.CIDALMACEN, loadRelatedDataOptions, cancellationToken);

if (loadRelatedDataOptions.CargarDatosExtra)
{
movimiento.DatosExtra =
(await _context.admMovimientos.FirstAsync(m => m.CIDMOVIMIENTO == movimientoSql.CIDMOVIMIENTO, cancellationToken))
.ToDatosDictionary<admMovimientos>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ private async Task CargarDatosRelacionadosAsync(Producto producto, ProductoDto p
ILoadRelatedDataOptions loadRelatedDataOptions, CancellationToken cancellationToken)
{
if (loadRelatedDataOptions.CargarDatosExtra)
{
producto.DatosExtra = (await _context.admProductos.FirstAsync(m => m.CIDPRODUCTO == productoSql.CIDPRODUCTO, cancellationToken))
.ToDatosDictionary<admProductos>();
}
}
}

0 comments on commit 0d91302

Please sign in to comment.