diff --git a/ARSoftware.Contpaqi.Comercial.sln.DotSettings b/ARSoftware.Contpaqi.Comercial.sln.DotSettings index 7badbeb5..c9b6d881 100644 --- a/ARSoftware.Contpaqi.Comercial.sln.DotSettings +++ b/ARSoftware.Contpaqi.Comercial.sln.DotSettings @@ -1,6 +1,200 @@  SUGGESTION SUGGESTION + <?xml version="1.0" encoding="utf-16"?> +<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> + <TypePattern DisplayName="Non-reorderable types"> + <TypePattern.Match> + <Or> + <And> + <Kind Is="Interface" /> + <Or> + <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> + <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> + </Or> + </And> + <Kind Is="Struct" /> + <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" /> + <HasAttribute Name="JetBrains.Annotations.NoReorder" /> + </Or> + </TypePattern.Match> + </TypePattern> + <TypePattern DisplayName="xUnit.net Test Classes" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <HasMember> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" Inherited="True" /> + <HasAttribute Name="Xunit.TheoryAttribute" Inherited="True" /> + </And> + </HasMember> + </And> + </TypePattern.Match> + <Entry DisplayName="Setup/Teardown Methods"> + <Entry.Match> + <Or> + <Kind Is="Constructor" /> + <And> + <Kind Is="Method" /> + <ImplementsInterface Name="System.IDisposable" /> + </And> + </Or> + </Entry.Match> + <Entry.SortBy> + <Kind Order="Constructor" /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="All other members" /> + <Entry DisplayName="Test Methods" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" /> + <HasAttribute Name="Xunit.TheoryAttribute" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <Or> + <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.TestFixtureSourceAttribute" Inherited="True" /> + <HasMember> + <And> + <Kind Is="Method" /> + <HasAttribute Name="NUnit.Framework.TestAttribute" /> + <HasAttribute Name="NUnit.Framework.TestCaseAttribute" /> + <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" /> + </And> + </HasMember> + </Or> + </And> + </TypePattern.Match> + <Entry DisplayName="Setup/Teardown Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <Or> + <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.TestFixtureSetUpAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.TestFixtureTearDownAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.OneTimeSetUpAttribute" Inherited="True" /> + <HasAttribute Name="NUnit.Framework.OneTimeTearDownAttribute" Inherited="True" /> + </Or> + </And> + </Entry.Match> + </Entry> + <Entry DisplayName="All other members" /> + <Entry DisplayName="Test Methods" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="NUnit.Framework.TestAttribute" /> + <HasAttribute Name="NUnit.Framework.TestCaseAttribute" /> + <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + <TypePattern DisplayName="Default Pattern"> + <Entry DisplayName="Public Delegates" Priority="100"> + <Entry.Match> + <And> + <Access Is="Public" /> + <Kind Is="Delegate" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="Public Enums" Priority="100"> + <Entry.Match> + <And> + <Access Is="Public" /> + <Kind Is="Enum" /> + </And> + </Entry.Match> + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="Static Fields and Constants"> + <Entry.Match> + <Or> + <Kind Is="Constant" /> + <And> + <Kind Is="Field" /> + <Static /> + </And> + </Or> + </Entry.Match> + <Entry.SortBy> + <Kind Order="Constant Field" /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="Fields"> + <Entry.Match> + <And> + <Kind Is="Field" /> + <Not> + <Static /> + </Not> + </And> + </Entry.Match> + <Entry.SortBy> + <Readonly /> + <Name /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="Constructors"> + <Entry.Match> + <Kind Is="Constructor" /> + </Entry.Match> + <Entry.SortBy> + <Static /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="Properties, Indexers"> + <Entry.Match> + <Or> + <Kind Is="Property" /> + <Kind Is="Indexer" /> + </Or> + </Entry.Match> + </Entry> + <Entry DisplayName="Interface Implementations" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Member" /> + <ImplementsInterface /> + </And> + </Entry.Match> + <Entry.SortBy> + <ImplementsInterface /> + <Name /> + </Entry.SortBy> + </Entry> + <Entry DisplayName="All other members" /> + <Entry DisplayName="Nested Types"> + <Entry.Match> + <Kind Is="Type" /> + </Entry.Match> + </Entry> + </TypePattern> +</Patterns> diff --git a/samples/Sql.ConsoleApp/Agentes/BuscarAgentesConRepositorio.cs b/samples/Sql.ConsoleApp/Agentes/BuscarAgentesConRepositorio.cs index 7e1d1a3c..a82d0f7a 100644 --- a/samples/Sql.ConsoleApp/Agentes/BuscarAgentesConRepositorio.cs +++ b/samples/Sql.ConsoleApp/Agentes/BuscarAgentesConRepositorio.cs @@ -20,7 +20,7 @@ public BuscarAgentesConRepositorio(IAgenteRepository agenteRepositor /// public void BuscarPorCodigo() { - var codigoAgente = "1"; + var codigoAgente = "PRUEBA"; admAgentes? agente = _agenteRepository.BuscarPorCodigo(codigoAgente); diff --git a/samples/Sql.ConsoleApp/Agentes/BuscarAgentesDtoConRepositorio.cs b/samples/Sql.ConsoleApp/Agentes/BuscarAgentesDtoConRepositorio.cs index d3feaec2..5a696ac0 100644 --- a/samples/Sql.ConsoleApp/Agentes/BuscarAgentesDtoConRepositorio.cs +++ b/samples/Sql.ConsoleApp/Agentes/BuscarAgentesDtoConRepositorio.cs @@ -20,7 +20,7 @@ public BuscarAgentesDtoConRepositorio(IAgenteRepository agenteReposit /// public void BuscarPorCodigo() { - var codigoAgente = "1"; + var codigoAgente = "PRUEBA"; AgenteDto? agente = _agenteRepository.BuscarPorCodigo(codigoAgente); diff --git a/samples/Sql.ConsoleApp/Program.cs b/samples/Sql.ConsoleApp/Program.cs index a7d4768a..e99ee123 100644 --- a/samples/Sql.ConsoleApp/Program.cs +++ b/samples/Sql.ConsoleApp/Program.cs @@ -29,7 +29,13 @@ { // 1. Busca la clase con los ejemplos que quieras probar utilizando el proveedor de servicios. // 2. Ejecuta el metodo que quieras probar. - var ejemplo = host.Services.GetRequiredService(); + //var ejemplo = host.Services.GetRequiredService(); + //ejemplo.TraerTodo(); + + var ejemplo = host.Services.GetRequiredService(); + ejemplo.BuscarPorCodigo(); + ejemplo.BuscarPorId(); + ejemplo.TraerPorTipo(); ejemplo.TraerTodo(); } catch (Exception e) diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Common/ModelDtoMappings.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Common/ModelDtoMappings.cs index 71c276e4..dc1f5baa 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Common/ModelDtoMappings.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Common/ModelDtoMappings.cs @@ -9,19 +9,50 @@ public sealed class ModelDtoMappings : Profile { public ModelDtoMappings() { + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); - CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); + CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); CreateMap(); + + CreateMap(); } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/ConfigureServices.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/ConfigureServices.cs index 86babfba..331087f7 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/ConfigureServices.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/ConfigureServices.cs @@ -1,7 +1,6 @@ using System.Reflection; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; -using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; -using ARSoftware.Contpaqi.Comercial.Sql.Models.Generales; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Repositories; using Microsoft.Extensions.DependencyInjection; @@ -14,88 +13,69 @@ public static IServiceCollection AddContpaqiComercialSqlRepositories(this IServi { services.AddAutoMapper(Assembly.GetExecutingAssembly()); - services.Add(new ServiceDescriptor(typeof(AgenteSqlRepository), typeof(AgenteSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(AgenteSqlRepository<>), typeof(AgenteSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IAgenteRepository), typeof(AgenteSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IAgenteRepository<>), typeof(AgenteSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IAgenteSqlRepository<>), typeof(AgenteSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(AlmacenSqlRepository), typeof(AlmacenSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(AlmacenSqlRepository<>), typeof(AlmacenSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IAlmacenRepository), typeof(AlmacenSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IAlmacenRepository<>), typeof(AlmacenSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IAlmacenSqlRepository<>), typeof(AlmacenSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ClasificacionSqlRepository), typeof(ClasificacionSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ClasificacionSqlRepository<>), typeof(ClasificacionSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IClasificacionRepository), typeof(ClasificacionSqlRepository), - lifetime)); services.Add(new ServiceDescriptor(typeof(IClasificacionRepository<>), typeof(ClasificacionSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IClasificacionSqlRepository<>), typeof(ClasificacionSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ClienteProveedorSqlRepository), typeof(ClienteProveedorSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ClienteProveedorSqlRepository<>), typeof(ClienteProveedorSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IClienteProveedorRepository), typeof(ClienteProveedorSqlRepository), - lifetime)); services.Add(new ServiceDescriptor(typeof(IClienteProveedorRepository<>), typeof(ClienteProveedorSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IClienteProveedorSqlRepository<>), typeof(ClienteProveedorSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ConceptoDocumentoSqlRepository), typeof(ConceptoDocumentoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ConceptoDocumentoSqlRepository<>), typeof(ConceptoDocumentoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IConceptoDocumentoRepository), typeof(ConceptoDocumentoSqlRepository), - lifetime)); services.Add(new ServiceDescriptor(typeof(IConceptoDocumentoRepository<>), typeof(ConceptoDocumentoSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IConceptoDocumentoSqlRepository<>), typeof(ConceptoDocumentoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(DireccionSqlRepository), typeof(DireccionSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(DireccionSqlRepository<>), typeof(DireccionSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IDireccionRepository), typeof(DireccionSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IDireccionRepository<>), typeof(DireccionSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IDireccionSqlRepository<>), typeof(DireccionSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(DocumentoModeloSqlRepository), typeof(DocumentoModeloSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(DocumentoModeloSqlRepository<>), typeof(DocumentoModeloSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IDocumentoModeloRepository), typeof(DocumentoModeloSqlRepository), - lifetime)); services.Add(new ServiceDescriptor(typeof(IDocumentoModeloRepository<>), typeof(DocumentoModeloSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IDocumentoModeloSqlRepository<>), typeof(DocumentoModeloSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(DocumentoSqlRepository), typeof(DocumentoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(DocumentoSqlRepository<>), typeof(DocumentoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IDocumentoRepository), typeof(DocumentoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IDocumentoRepository<>), typeof(DocumentoSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IDocumentoSqlRepository<>), typeof(DocumentoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(EmpresaSqlRepository), typeof(EmpresaSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(EmpresaSqlRepository<>), typeof(EmpresaSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IEmpresaRepository), typeof(EmpresaSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IEmpresaRepository<>), typeof(EmpresaSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IEmpresaSqlRepository<>), typeof(EmpresaSqlRepository<>), lifetime)); services.Add(new ServiceDescriptor(typeof(IExistenciasRepository), typeof(ExistenciasSqlRepository), lifetime)); + services.Add(new ServiceDescriptor(typeof(IExistenciasSqlRepository), typeof(ExistenciasSqlRepository), lifetime)); - services.Add(new ServiceDescriptor(typeof(MonedaSqlRepository), typeof(MonedaSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(MonedaSqlRepository<>), typeof(MonedaSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IMonedaRepository), typeof(MonedaSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IMonedaRepository<>), typeof(MonedaSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IMonedaSqlRepository<>), typeof(MonedaSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(MovimientoSqlRepository), typeof(MovimientoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(MovimientoSqlRepository<>), typeof(MovimientoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IMovimientoRepository), typeof(MovimientoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IMovimientoRepository<>), typeof(MovimientoSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IMovimientoSqlRepository<>), typeof(MovimientoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ParametrosSqlRepository), typeof(ParametrosSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ParametrosSqlRepository<>), typeof(ParametrosSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IParametrosRepository), typeof(ParametrosSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IParametrosRepository<>), typeof(ParametrosSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IParametrosSqlRepository<>), typeof(ParametrosSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ProductoSqlRepository), typeof(ProductoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ProductoSqlRepository<>), typeof(ProductoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IProductoRepository), typeof(ProductoSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IProductoRepository<>), typeof(ProductoSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IProductoSqlRepository<>), typeof(ProductoSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(UnidadMedidaSqlRepository), typeof(UnidadMedidaSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(UnidadMedidaSqlRepository<>), typeof(UnidadMedidaSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IUnidadMedidaRepository), typeof(UnidadMedidaSqlRepository), - lifetime)); services.Add(new ServiceDescriptor(typeof(IUnidadMedidaRepository<>), typeof(UnidadMedidaSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IUnidadMedidaSqlRepository<>), typeof(UnidadMedidaSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(ValorClasificacionSqlRepository), typeof(ValorClasificacionSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(ValorClasificacionSqlRepository<>), typeof(ValorClasificacionSqlRepository<>), lifetime)); - services.Add(new ServiceDescriptor(typeof(IValorClasificacionRepository), - typeof(ValorClasificacionSqlRepository), lifetime)); services.Add(new ServiceDescriptor(typeof(IValorClasificacionRepository<>), typeof(ValorClasificacionSqlRepository<>), lifetime)); + services.Add(new ServiceDescriptor(typeof(IValorClasificacionSqlRepository<>), typeof(ValorClasificacionSqlRepository<>), + lifetime)); return services; } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAgenteSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAgenteSqlRepository.cs new file mode 100644 index 00000000..1eaea864 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAgenteSqlRepository.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IAgenteSqlRepository : IAgenteRepository where T : class, new() +{ + /// + /// Busca un agente por código. + /// + /// + /// Código del agente a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un agente, o si no existe un agente con el código proporcionado. + /// + Task BuscarPorCodigoAsync(string codigoAgente, CancellationToken cancellationToken); + + /// + /// Busca un agente por id. + /// + /// + /// Id del agente a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un agente, o si no existe un agente con el id proporcionado. + /// + Task BuscarPorIdAsync(int idAgente, CancellationToken cancellationToken); + + /// + /// Busca todos los agentes de un tipo. + /// + /// + /// Tipo de los agentes a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de agentes. + /// + Task> TraerPorTipoAsync(TipoAgente tipoAgente, CancellationToken cancellationToken); + + /// + /// Busca todos los agentes. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de agentes. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAlmacenSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAlmacenSqlRepository.cs new file mode 100644 index 00000000..ee658bc1 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IAlmacenSqlRepository.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IAlmacenSqlRepository : IAlmacenRepository where T : class, new() +{ + /// + /// Busca un almacén por código. + /// + /// Código del almacén a buscar. + /// + /// Token de cancelación. + /// + /// + /// Un almacén, o si no existe un almacén con el código proporcionado. + /// + Task BuscarPorCodigoAsync(string codigoAlmacen, CancellationToken cancellationToken); + + /// + /// Busca un almacén por id. + /// + /// + /// Id del almacén a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un almacén, o si no existe un almacén con el id proporcionado. + /// + Task BuscarPorIdAsync(int idAlmacen, CancellationToken cancellationToken); + + /// + /// Busca todos los almacenes. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de almacenes. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClasificacionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClasificacionSqlRepository.cs new file mode 100644 index 00000000..65401519 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClasificacionSqlRepository.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IClasificacionSqlRepository : IClasificacionRepository where T : class, new() +{ + /// + /// Busca una clasificación por id. + /// + /// + /// Id de la clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una clasificación, o si no existe una clasificación con el id proporcionado. + /// + Task BuscarPorIdAsyc(int idClasificacion, CancellationToken cancellationToken); + + /// + /// Busca una clasificación por tipo y número. + /// + /// + /// Tipo de la clasificación a buscar. + /// + /// + /// Número de la clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una clasificación, o si no existe una clasificación con el tipo y número proporcionados. + /// + Task BuscarPorTipoYNumeroAsync(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, + CancellationToken cancellationToken); + + /// + /// Busca todas las clasificaciones de un tipo. + /// + /// + /// Tipo de las clasificaciones a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de clasificaciones. + /// + Task> TraerPorTipoAsync(TipoClasificacion tipoClasificacion, CancellationToken cancellationToken); + + /// + /// Busca todas las clasificaciones. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de clasificaciones. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClienteProveedorSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClienteProveedorSqlRepository.cs new file mode 100644 index 00000000..8db8020c --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IClienteProveedorSqlRepository.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +/// "/> +public interface IClienteProveedorSqlRepository : IClienteProveedorRepository where T : class, new() +{ + /// + /// Busca un cliente o proveedor por código. + /// + /// + /// Código del cliente o proveedor a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un cliente o proveedor, o si no existe un cliente o proveedor con el código proporcionado. + /// + Task BuscarPorCodigoAsync(string codigoCliente, CancellationToken cancellationToken); + + /// + /// Busca un cliente o proveedor por id. + /// + /// + /// Id del cliente o proveedor a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un cliente o proveedor, o si no existe un cliente o proveedor con el id proporcionado. + /// + Task BuscarPorIdAsync(int idCliente, CancellationToken cancellationToken); + + /// + /// Busca todos los clientes. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de clientes. + /// + Task> TraerClientesAsync(CancellationToken cancellationToken); + + /// + /// Busca clientes o proveedores por tipo. + /// + /// + /// Tipo de los clientes o proveedores a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de clientes o proveedores. + /// + Task> TraerPorTipoAsync(TipoCliente tipoCliente, CancellationToken cancellationToken); + + /// + /// Busca todos los proveedores. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de proveedores. + /// + Task> TraerProveedoresAsync(CancellationToken cancellationToken); + + /// + /// Busca todos los clientes y proveedores. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de clientes y proveedores. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IConceptoDocumentoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IConceptoDocumentoSqlRepository.cs new file mode 100644 index 00000000..d73490dc --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IConceptoDocumentoSqlRepository.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IConceptoDocumentoSqlRepository : IConceptoDocumentoRepository where T : class, new() +{ + /// + /// Busca un concepto de documento por código. + /// + /// + /// Código del concepto de documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un concepto de documento, o si no existe un concepto de documento con el código + /// proporcionado. + /// + Task BuscarPorCodigoAsync(string codigoConcepto, CancellationToken cancellationToken); + + /// + /// Busca un concepto de documento por id. + /// + /// + /// Id del concepto de documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un concepto de documento, o si no existe un concepto de documento con el id proporcionado. + /// + Task BuscarPorIdAsync(int idConcepto, CancellationToken cancellationToken); + + /// + /// Busca conceptos de documento por documento modelo. + /// + /// + /// Id del documento modelo de los conceptos de documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de conceptos de documento. + /// + Task> TraerPorDocumentoModeloIdAsync(int idDocumentoModelo, CancellationToken cancellationToken); + + /// + /// Busca todos los conceptos de documento. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de conceptos de documento. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDireccionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDireccionSqlRepository.cs new file mode 100644 index 00000000..81cd2dc2 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDireccionSqlRepository.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IDireccionSqlRepository : IDireccionRepository where T : class, new() +{ + /// + /// Busca una dirección por cliente. + /// + /// + /// Código del cliente o proveedor de la dirección a buscar. + /// + /// + /// Tipo de la dirección a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una dirección, o si no existe una dirección con el código de cliente o proveedor y tipo de + /// dirección proporcionados. + /// + Task BuscarPorClienteAsync(string codigoClienteProveedor, TipoDireccion tipoDireccion, CancellationToken cancellationToken); + + /// + /// Busca una dirección por documento. + /// + /// + /// Id del documento de la dirección a buscar. + /// + /// + /// Tipo de la dirección a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una dirección, o si no existe una dirección con el id de documento y tipo de dirección + /// proporcionados. + /// + Task BuscarPorDocumentoAsync(int idDocumento, TipoDireccion tipoDireccion, CancellationToken cancellationToken); + + /// + /// Busca una dirección por id. + /// + /// + /// Id de la dirección a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una dirección, o si no existe una dirección con el id proporcionado. + /// + Task BuscarPorIdAsync(int idDireccion, CancellationToken cancellationToken); + + /// + /// Busca direcciones por tipo de catálogo de dirección. + /// + /// + /// Tipo de catálogo de dirección de las direcciones a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de direcciones. + /// + Task> TraerPorTipoAsync(TipoCatalogoDireccion tipoCatalogoDireccion, CancellationToken cancellationToken); + + /// + /// Busca direcciones por tipo de catálogo de dirección y id de catálogo. + /// + /// + /// Tipo de catálogo de dirección de las direcciones a buscar. + /// + /// + /// Id del catálogo de las direcciones a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de direcciones. + /// + Task> TraerPorTipoYIdCatalogoAsync(TipoCatalogoDireccion tipoCatalogoDireccion, int idCatalogo, + CancellationToken cancellationToken); + + /// + /// Busca todas las direcciones. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de direcciones. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoModeloSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoModeloSqlRepository.cs new file mode 100644 index 00000000..2478784d --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoModeloSqlRepository.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IDocumentoModeloSqlRepository : IDocumentoModeloRepository where T : class, new() +{ + /// + /// Busca todos los documentos modelo. + /// + /// + /// Lista de documentos modelo. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoSqlRepository.cs new file mode 100644 index 00000000..9ce38bcd --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IDocumentoSqlRepository.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Models; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IDocumentoSqlRepository : IDocumentoRepository where T : class, new() +{ + /// + /// Busca un documento por id. + /// + /// + /// Id del documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un documento, o si no existe un documento con el id proporcionado. + /// + Task BuscarPorIdAsync(int idDocumento, CancellationToken cancellationToken); + + /// + /// Busca un documento por llave. + /// + /// + /// Código del concepto del documento a buscar. + /// + /// + /// Serie del documento a buscar. + /// + /// + /// Folio del documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un documento, o si no existe un documento con la llave proporcionada. + /// + Task BuscarPorLlaveAsync(string codigoConcepto, string serie, double folio, CancellationToken cancellationToken); + + /// + /// Busca un documento por llave. + /// + /// + /// Llave del documento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un documento, o si no existe un documento con la llave proporcionada. + /// + Task BuscarPorLlaveAsync(LlaveDocumento llaveDocumento, CancellationToken cancellationToken); + + /// + /// Busca documentos por rango de fecha, código de concepto y código de cliente/proveedor. + /// + /// + /// Fecha de inicio del rango de fecha. + /// + /// + /// Fecha de fin del rango de fecha. + /// + /// + /// Código de concepto de los documentos a buscar. + /// + /// + /// Código de cliente/proveedor de los documentos a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de documentos. + /// + Task> TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedorAsync(DateTime fechaInicio, DateTime fechaFin, + string codigoConcepto, string codigoClienteProveedor, CancellationToken cancellationToken); + + /// + /// Busca documentos por rango de fecha, código de concepto y códigos de cliente/proveedor. + /// + /// + /// Fecha de inicio del rango de fecha. + /// + /// + /// Fecha de fin del rango de fecha. + /// + /// + /// Código de concepto de los documentos a buscar. + /// + /// + /// Códigos de cliente/proveedor de los documentos a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de documentos. + /// + Task> TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedorAsync(DateTime fechaInicio, DateTime fechaFin, + string codigoConcepto, IEnumerable codigosClienteProveedor, CancellationToken cancellationToken); + + /// + /// Buscar todos los documentos. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de documentos. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IEmpresaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IEmpresaSqlRepository.cs new file mode 100644 index 00000000..76d36b66 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IEmpresaSqlRepository.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IEmpresaSqlRepository : IEmpresaRepository where T : class, new() +{ + /// + /// Busca una empresa por su nombre. + /// + /// + /// Nombre de la empresa a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una empresa, o si no existe una empresa con el nombre proporcionado. + /// + Task BuscarPorNombreAsync(string nombreEmpresa, CancellationToken cancellationToken); + + /// + /// Busca todas las empresas. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de empresas. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IExistenciasSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IExistenciasSqlRepository.cs new file mode 100644 index 00000000..2ef5aed7 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IExistenciasSqlRepository.cs @@ -0,0 +1,60 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +/// "/> +public interface IExistenciasSqlRepository : IExistenciasRepository +{ + /// + /// Busca las existencias de un producto en un almacén en una fecha determinada. + /// + /// Código del producto. + /// Código del almacén. + /// Fecha + /// + /// Token de cancelación. + /// + /// + /// Las existencias del producto en el almacén en la fecha proporcionada. + /// + Task BuscaExistenciasAsync(string codigoProducto, string codigoAlmacen, DateOnly fecha, CancellationToken cancellationToken); + + /// + /// Busca las existencias de un producto con características en un almacén en una fecha determinada. + /// + /// Código del producto. + /// Código del almacén. + /// Fecha + /// Abreviatura del Valor de la Característica 1 del producto. + /// Abreviatura del Valor de la Característica 2 del producto. + /// Abreviatura del Valor de la Característica 3 del producto. + /// + /// Token de cancelación. + /// + /// + /// Las existencias del producto con características en el almacén en la fecha proporcionada. + /// + Task BuscaExistenciasConCaracteristicasAsync(string codigoProducto, string codigoAlmacen, DateOnly fecha, + string abreviaturaValorCaracteristica1, string abreviaturaValorCaracteristica2, string abreviaturaValorCaracteristica3, + CancellationToken cancellationToken); + + /// + /// Busca las existencias de un producto por lote y/o pedimento. + /// + /// Código del producto. + /// Código del almacén. + /// Numero de pedimento. + /// Numero de lote. + /// + /// Token de cancelación. + /// + /// + /// Las existencias del producto por lote y/o pedimento. + /// + Task BuscaExistenciasConCapasAsync(string codigoProducto, string codigoAlmacen, string pedimento, string lote, + CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMonedaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMonedaSqlRepository.cs new file mode 100644 index 00000000..859bb4ab --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMonedaSqlRepository.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IMonedaSqlRepository : IMonedaRepository where T : class, new() +{ + /// + /// Busca una moneda por id. + /// + /// + /// Id de la moneda a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una moneda, o si no existe una moneda con el id proporcionado. + /// + Task BuscarPorIdAsync(int idMoneda, CancellationToken cancellationToken); + + /// + /// Busca una moneda por nombre. + /// + /// + /// Nombre de la moneda a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una moneda, o si no existe una moneda con el nombre proporcionado. + /// + Task BuscarPorNombreAsync(string nombreMoneda, CancellationToken cancellationToken); + + /// + /// Busca todas las monedas. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de monedas. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMovimientoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMovimientoSqlRepository.cs new file mode 100644 index 00000000..c26d1fc3 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IMovimientoSqlRepository.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IMovimientoSqlRepository : IMovimientoRepository where T : class, new() +{ + /// + /// Busca un movimiento por id. + /// + /// + /// Id del movimiento a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un movimiento, o si no existe un movimiento con el id proporcionado. + /// + Task BuscarPorIdAsync(int idMovimiento, CancellationToken cancellationToken); + + /// + /// Busca movimientos por id de documento. + /// + /// + /// Id de documento de los movimientos a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de movimientos. + /// + Task> TraerPorDocumentoIdAsync(int idDocumento, CancellationToken cancellationToken); + + /// + /// Busca todos los movimientos. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de movimientos. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IParametrosSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IParametrosSqlRepository.cs new file mode 100644 index 00000000..d35d618f --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IParametrosSqlRepository.cs @@ -0,0 +1,20 @@ +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IParametrosSqlRepository : IParametrosRepository where T : class, new() +{ + /// + /// Busca los parámetros de la empresa. + /// + /// + /// Token de cancelación. + /// + /// + /// Los parámetros de la empresa. + /// + Task BuscarAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IProductoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IProductoSqlRepository.cs new file mode 100644 index 00000000..9419c58a --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IProductoSqlRepository.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IProductoSqlRepository : IProductoRepository where T : class, new() +{ + /// + /// Busca un producto por código. + /// + /// + /// Código del producto a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un producto, o si no existe un producto con el código proporcionado. + /// + Task BuscarPorCodigoAsync(string codigoProducto, CancellationToken cancellationToken); + + /// + /// Busca un producto por id. + /// + /// + /// Id del producto a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un producto, o si no existe un producto con el id proporcionado. + /// + Task BuscarPorIdAsync(int idProducto, CancellationToken cancellationToken); + + /// + /// Busca productos por tipo. + /// + /// + /// Tipo de los producto a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de productos. + /// + Task> TraerPorTipoAsync(TipoProducto tipoProducto, CancellationToken cancellationToken); + + /// + /// Busca todos los productos. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de productos. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IUnidadMedidaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IUnidadMedidaSqlRepository.cs new file mode 100644 index 00000000..f4244fce --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IUnidadMedidaSqlRepository.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IUnidadMedidaSqlRepository : IUnidadMedidaRepository where T : class, new() +{ + /// + /// Busca una unidad de medida por id. + /// + /// + /// Id de la unidad de medida a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una unidad de medida, o si no existe una unidad de medida con el id proporcionado. + /// + Task BuscarPorIdAsync(int idUnidad, CancellationToken cancellationToken); + + /// + /// Busca una unidad de medida por nombre. + /// + /// + /// Nombre de la unidad de medida a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Una unidad de medida, o si no existe una unidad de medida con el nombre proporcionado. + /// + Task BuscarPorNombreAsync(string nombreUnidad, CancellationToken cancellationToken); + + /// + /// Busca todas las unidades de medida. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de unidades de medida. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IValorClasificacionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IValorClasificacionSqlRepository.cs new file mode 100644 index 00000000..ba15c616 --- /dev/null +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Interfaces/IValorClasificacionSqlRepository.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; +using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; + +namespace ARSoftware.Contpaqi.Comercial.Sql.Interfaces; + +/// +public interface IValorClasificacionSqlRepository : IValorClasificacionRepository where T : class, new() +{ + /// + /// Busca un valor de clasificación por id. + /// + /// + /// Id del valor de clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un valor de clasificación, o si no existe un valor de clasificación con el id + /// proporcionado. + /// + Task BuscarPorIdAsync(int idValorClasificacion, CancellationToken cancellationToken); + + /// + /// Busca un valor de clasificación por tipo de clasificación, número de clasificación y código. + /// + /// + /// Tipo de clasificación del valor de clasificación a buscar. + /// + /// + /// Número de clasificación del valor de clasificación a buscar. + /// + /// + /// Código del valor de clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Un valor de clasificación, o si no existe un valor de clasificación con el tipo de + /// clasificación, número de clasificación y código proporcionados. + /// + Task BuscarPorTipoClasificacionNumeroYCodigoAsync(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, + string codigoValorClasificacion, CancellationToken cancellationToken); + + /// + /// Busca valores de clasificación por id de clasificación. + /// + /// + /// Id de la clasificación de los valores de clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de valores de clasificación. + /// + Task> TraerPorClasificacionIdAsync(int idClasificacion, CancellationToken cancellationToken); + + /// + /// Busca valores de clasificación por tipo de clasificación y número de clasificación. + /// + /// + /// Tipo de clasificación de los valores de clasificación a buscar. + /// + /// + /// Número de clasificación de los valores de clasificación a buscar. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de valores de clasificación. + /// + Task> TraerPorClasificacionTipoYNumeroAsync(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, + CancellationToken cancellationToken); + + /// + /// Busca todos los valores de clasificación. + /// + /// + /// Token de cancelación. + /// + /// + /// Lista de valores de clasificación. + /// + Task> TraerTodoAsync(CancellationToken cancellationToken); +} diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AgenteSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AgenteSqlRepository.cs index 2abb57cd..3528336e 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AgenteSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AgenteSqlRepository.cs @@ -1,61 +1,28 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Agentes; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar agentes. -/// -public sealed class AgenteSqlRepository : ContpaqiComercialSqlRepositoryBase, IAgenteRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public AgenteSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admAgentes? BuscarPorCodigo(string codigoAgente) - { - return _context.admAgentes.WithSpecification(new AgentePorCodigoSpecification(codigoAgente)).SingleOrDefault(); - } - - /// - public admAgentes? BuscarPorId(int idAgente) - { - return _context.admAgentes.WithSpecification(new AgentePorIdSpecification(idAgente)).SingleOrDefault(); - } - - /// - public List TraerPorTipo(TipoAgente tipoAgente) - { - return _context.admAgentes.WithSpecification(new AgentePorTipoSpecification(tipoAgente)).ToList(); - } - - /// - public List TraerTodo() - { - return _context.admAgentes.ToList(); - } -} - /// /// Repositorio de SQL para consultar agentes y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los agentes. /// -public class AgenteSqlRepository : ContpaqiComercialSqlRepositoryBase, IAgenteRepository where T : class, new() +public sealed class AgenteSqlRepository : ContpaqiComercialSqlRepositoryBase, IAgenteSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -95,4 +62,34 @@ public List TraerTodo() { return _context.admAgentes.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorCodigoAsync(string codigoAgente, CancellationToken cancellationToken) + { + return await _context.admAgentes.WithSpecification(new AgentePorCodigoSpecification(codigoAgente)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorIdAsync(int idAgente, CancellationToken cancellationToken) + { + return await _context.admAgentes.WithSpecification(new AgentePorIdSpecification(idAgente)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerPorTipoAsync(TipoAgente tipoAgente, CancellationToken cancellationToken) + { + return await _context.admAgentes.WithSpecification(new AgentePorTipoSpecification(tipoAgente)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admAgentes.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AlmacenSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AlmacenSqlRepository.cs index 5478af70..e4757694 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AlmacenSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/AlmacenSqlRepository.cs @@ -1,54 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Almacenes; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar almacenes. -/// -public sealed class AlmacenSqlRepository : ContpaqiComercialSqlRepositoryBase, IAlmacenRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public AlmacenSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admAlmacenes? BuscarPorCodigo(string codigoAlmacen) - { - return _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)).SingleOrDefault(); - } - - /// - public admAlmacenes? BuscarPorId(int idAlmacen) - { - return _context.admAlmacenes.WithSpecification(new AlmacenPorIdSpecification(idAlmacen)).SingleOrDefault(); - } - - /// - public List TraerTodo() - { - return _context.admAlmacenes.ToList(); - } -} - /// /// Repositorio de SQL para consultar almacenes y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los almacenes. /// -public class AlmacenSqlRepository : ContpaqiComercialSqlRepositoryBase, IAlmacenRepository where T : class, new() +public sealed class AlmacenSqlRepository : ContpaqiComercialSqlRepositoryBase, IAlmacenSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -81,4 +54,26 @@ public List TraerTodo() { return _context.admAlmacenes.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorCodigoAsync(string codigoAlmacen, CancellationToken cancellationToken) + { + return await _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorIdAsync(int idAlmacen, CancellationToken cancellationToken) + { + return await _context.admAlmacenes.WithSpecification(new AlmacenPorIdSpecification(idAlmacen)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admAlmacenes.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClasificacionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClasificacionSqlRepository.cs index 0dda8458..6d12ee36 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClasificacionSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClasificacionSqlRepository.cs @@ -1,65 +1,28 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Clasificaciones; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar clasificaciones. -/// -public sealed class ClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, - IClasificacionRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public ClasificacionSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admClasificaciones? BuscarPorId(int idClasificacion) - { - return _context.admClasificaciones.WithSpecification(new ClasificacionPorIdSpecification(idClasificacion)).SingleOrDefault(); - } - - /// - public admClasificaciones? BuscarPorTipoYNumero(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion) - { - return _context.admClasificaciones - .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) - .SingleOrDefault(); - } - - /// - public List TraerPorTipo(TipoClasificacion tipoClasificacion) - { - return _context.admClasificaciones.WithSpecification(new ClasificacionesPorTipoSpecification(tipoClasificacion)).ToList(); - } - - /// - public List TraerTodo() - { - return _context.admClasificaciones.ToList(); - } -} - /// /// Repositorio de SQL para consultar clasificaciones y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean las clasificaciones. /// -public class ClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, IClasificacionRepository - where T : class, new() +public sealed class ClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, + IClasificacionSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -101,4 +64,36 @@ public List TraerTodo() { return _context.admClasificaciones.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorIdAsyc(int idClasificacion, CancellationToken cancellationToken) + { + return await _context.admClasificaciones.WithSpecification(new ClasificacionPorIdSpecification(idClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorTipoYNumeroAsync(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, + CancellationToken cancellationToken) + { + return await _context.admClasificaciones + .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerPorTipoAsync(TipoClasificacion tipoClasificacion, CancellationToken cancellationToken) + { + return await _context.admClasificaciones.WithSpecification(new ClasificacionesPorTipoSpecification(tipoClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admClasificaciones.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClienteProveedorSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClienteProveedorSqlRepository.cs index db849cba..aafe160f 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClienteProveedorSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ClienteProveedorSqlRepository.cs @@ -1,124 +1,123 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Clientes; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; /// -/// Repositorio de SQL para consultar clientes y proveedores. +/// Repositorio de SQL para consultar clientes y proveedores y transformarlos a un tipo destino utilizando AutoMapper. /// -public sealed class ClienteProveedorSqlRepository : ContpaqiComercialSqlRepositoryBase, - IClienteProveedorRepository +/// +/// Tipo del objecto destino al que se mapean los clientes y proveedores. +/// +public sealed class ClienteProveedorSqlRepository : ContpaqiComercialSqlRepositoryBase, IClienteProveedorSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; + private readonly IMapper _mapper; - public ClienteProveedorSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) + public ClienteProveedorSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) { _context = context; + _mapper = mapper; } /// - public admClientes? BuscarPorCodigo(string codigoCliente) + public T? BuscarPorCodigo(string codigoCliente) { - return _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoCliente)).SingleOrDefault(); + return _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoCliente)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefault(); } /// - public admClientes? BuscarPorId(int idCliente) + public T? BuscarPorId(int idCliente) { - return _context.admClientes.WithSpecification(new ClientePorIdSpecification(idCliente)).SingleOrDefault(); + return _context.admClientes.WithSpecification(new ClientePorIdSpecification(idCliente)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefault(); } /// - public List TraerClientes() + public List TraerClientes() { - return _context.admClientes.WithSpecification(new ClientesSpecification()).ToList(); + return _context.admClientes.WithSpecification(new ClientesSpecification()).ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public List TraerPorTipo(TipoCliente tipoCliente) + public List TraerPorTipo(TipoCliente tipoCliente) { - return _context.admClientes.WithSpecification(new ClientesPorTipoSpecification(tipoCliente)).ToList(); + return _context.admClientes.WithSpecification(new ClientesPorTipoSpecification(tipoCliente)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToList(); } /// - public List TraerProveedores() + public List TraerProveedores() { - return _context.admClientes.WithSpecification(new ProveedoresSpecification()).ToList(); + return _context.admClientes.WithSpecification(new ProveedoresSpecification()).ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public List TraerTodo() - { - return _context.admClientes.ToList(); - } -} - -/// -/// Repositorio de SQL para consultar clientes y proveedores y transformarlos a un tipo destino utilizando AutoMapper. -/// -/// -/// Tipo del objecto destino al que se mapean los clientes y proveedores. -/// -public sealed class ClienteProveedorSqlRepository : ContpaqiComercialSqlRepositoryBase, IClienteProveedorRepository - where T : class, new() -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - private readonly IMapper _mapper; - - public ClienteProveedorSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) + public List TraerTodo() { - _context = context; - _mapper = mapper; + return _context.admClientes.ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public T? BuscarPorCodigo(string codigoCliente) + public async Task BuscarPorCodigoAsync(string codigoCliente, CancellationToken cancellationToken) { - return _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoCliente)) + return await _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoCliente)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorId(int idCliente) + public async Task BuscarPorIdAsync(int idCliente, CancellationToken cancellationToken) { - return _context.admClientes.WithSpecification(new ClientePorIdSpecification(idCliente)) + return await _context.admClientes.WithSpecification(new ClientePorIdSpecification(idCliente)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public List TraerClientes() + public async Task> TraerClientesAsync(CancellationToken cancellationToken) { - return _context.admClientes.WithSpecification(new ClientesSpecification()).ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admClientes.WithSpecification(new ClientesSpecification()) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); } /// - public List TraerPorTipo(TipoCliente tipoCliente) + public async Task> TraerPorTipoAsync(TipoCliente tipoCliente, CancellationToken cancellationToken) { - return _context.admClientes.WithSpecification(new ClientesPorTipoSpecification(tipoCliente)) + return await _context.admClientes.WithSpecification(new ClientesPorTipoSpecification(tipoCliente)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerProveedores() + public async Task> TraerProveedoresAsync(CancellationToken cancellationToken) { - return _context.admClientes.WithSpecification(new ProveedoresSpecification()).ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admClientes.WithSpecification(new ProveedoresSpecification()) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); } /// - public List TraerTodo() + public async Task> TraerTodoAsync(CancellationToken cancellationToken) { - return _context.admClientes.ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admClientes.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ConceptoDocumentoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ConceptoDocumentoSqlRepository.cs index bd6a9fd7..5c306c78 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ConceptoDocumentoSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ConceptoDocumentoSqlRepository.cs @@ -1,62 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Conceptos; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar conceptos de documento. -/// -public sealed class ConceptoDocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, - IConceptoDocumentoRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public ConceptoDocumentoSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admConceptos? BuscarPorCodigo(string codigoConcepto) - { - return _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault(); - } - - /// - public admConceptos? BuscarPorId(int idConcepto) - { - return _context.admConceptos.WithSpecification(new ConceptoPorIdSpecification(idConcepto)).SingleOrDefault(); - } - - /// - public List TraerPorDocumentoModeloId(int idDocumentoModelo) - { - return _context.admConceptos.WithSpecification(new ConceptosPorDocumentoModeloIdSpecification(idDocumentoModelo)).ToList(); - } - - /// - public List TraerTodo() - { - return _context.admConceptos.ToList(); - } -} - /// /// Repositorio de SQL para consultar conceptos de documento y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los conceptos de documento. /// -public sealed class ConceptoDocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, IConceptoDocumentoRepository - where T : class, new() +public sealed class ConceptoDocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, + IConceptoDocumentoSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -96,4 +61,34 @@ public List TraerTodo() { return _context.admConceptos.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorCodigoAsync(string codigoConcepto, CancellationToken cancellationToken) + { + return await _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorIdAsync(int idConcepto, CancellationToken cancellationToken) + { + return await _context.admConceptos.WithSpecification(new ConceptoPorIdSpecification(idConcepto)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerPorDocumentoModeloIdAsync(int idDocumentoModelo, CancellationToken cancellationToken) + { + return await _context.admConceptos.WithSpecification(new ConceptosPorDocumentoModeloIdSpecification(idDocumentoModelo)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admConceptos.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DireccionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DireccionSqlRepository.cs index 330676d0..519c281b 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DireccionSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DireccionSqlRepository.cs @@ -1,142 +1,146 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Clientes; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Direcciones; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; /// -/// Repositorio de SQL para consultar direcciones. +/// Repositorio de SQL para consultar direcciones y transformarlos a un tipo destino utilizando AutoMapper. /// -public sealed class DireccionSqlRepository : ContpaqiComercialSqlRepositoryBase, IDireccionRepository +/// +/// Tipo del objecto destino al que se mapean las direcciones. +/// +public sealed class DireccionSqlRepository : ContpaqiComercialSqlRepositoryBase, IDireccionSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; + private readonly IMapper _mapper; - public DireccionSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) + public DireccionSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) { _context = context; + _mapper = mapper; } /// - public admDomicilios? BuscarPorCliente(string codigoClienteProveedor, TipoDireccion tipoDireccion) + public T? BuscarPorCliente(string codigoClienteProveedor, TipoDireccion tipoDireccion) { - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? - throw new ArgumentException($"El cliente con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); + var cliente = + _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(d => new { d.CIDCLIENTEPROVEEDOR }) + .SingleOrDefault() ?? throw new ArgumentException($"El cliente con codigo {codigoClienteProveedor} no existe.", + nameof(codigoClienteProveedor)); return _context.admDomicilios.WithSpecification(new DireccionesPorClienteSpecification(cliente.CIDCLIENTEPROVEEDOR, tipoDireccion)) + .ProjectTo(_mapper.ConfigurationProvider) .FirstOrDefault(); } /// - public admDomicilios? BuscarPorDocumento(int idDocumento, TipoDireccion tipoDireccion) + public T? BuscarPorDocumento(int idDocumento, TipoDireccion tipoDireccion) { return _context.admDomicilios.WithSpecification(new DireccionPorDocumentoSpecification(idDocumento, tipoDireccion)) + .ProjectTo(_mapper.ConfigurationProvider) .FirstOrDefault(); } /// - public admDomicilios? BuscarPorId(int idDireccion) + public T? BuscarPorId(int idDireccion) { - return _context.admDomicilios.WithSpecification(new DireccionPorIdSpecification(idDireccion)).SingleOrDefault(); + return _context.admDomicilios.WithSpecification(new DireccionPorIdSpecification(idDireccion)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefault(); } /// - public List TraerPorTipo(TipoCatalogoDireccion tipoCatalogoDireccion) + public List TraerPorTipo(TipoCatalogoDireccion tipoCatalogoDireccion) { - return _context.admDomicilios.WithSpecification(new DireccionPorTipoCatalogoSpecification(tipoCatalogoDireccion)).ToList(); + return _context.admDomicilios.WithSpecification(new DireccionPorTipoCatalogoSpecification(tipoCatalogoDireccion)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToList(); } /// - public List TraerPorTipoYIdCatalogo(TipoCatalogoDireccion tipoCatalogoDireccion, int idCatalogo) + public List TraerPorTipoYIdCatalogo(TipoCatalogoDireccion tipoCatalogoDireccion, int idCatalogo) { return _context.admDomicilios .WithSpecification(new DireccionPorTipoCatalogoYIdCatalogoSpecification(tipoCatalogoDireccion, idCatalogo)) + .ProjectTo(_mapper.ConfigurationProvider) .ToList(); } /// - public List TraerTodo() - { - return _context.admDomicilios.ToList(); - } -} - -/// -/// Repositorio de SQL para consultar direcciones y transformarlos a un tipo destino utilizando AutoMapper. -/// -/// -/// Tipo del objecto destino al que se mapean las direcciones. -/// -public sealed class DireccionSqlRepository : ContpaqiComercialSqlRepositoryBase, IDireccionRepository - where T : class, new() -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - private readonly IMapper _mapper; - - public DireccionSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) + public List TraerTodo() { - _context = context; - _mapper = mapper; + return _context.admDomicilios.ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public T? BuscarPorCliente(string codigoClienteProveedor, TipoDireccion tipoDireccion) + public async Task BuscarPorClienteAsync(string codigoClienteProveedor, TipoDireccion tipoDireccion, + CancellationToken cancellationToken) { - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? - throw new ArgumentException($"El cliente con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); - - return _context.admDomicilios.WithSpecification(new DireccionesPorClienteSpecification(cliente.CIDCLIENTEPROVEEDOR, tipoDireccion)) + var cliente = + _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(d => new { d.CIDCLIENTEPROVEEDOR }) + .SingleOrDefault() ?? throw new ArgumentException($"El cliente con codigo {codigoClienteProveedor} no existe.", + nameof(codigoClienteProveedor)); + + return await _context.admDomicilios + .WithSpecification(new DireccionesPorClienteSpecification(cliente.CIDCLIENTEPROVEEDOR, tipoDireccion)) .ProjectTo(_mapper.ConfigurationProvider) - .FirstOrDefault(); + .FirstOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorDocumento(int idDocumento, TipoDireccion tipoDireccion) + public async Task BuscarPorDocumentoAsync(int idDocumento, TipoDireccion tipoDireccion, CancellationToken cancellationToken) { - return _context.admDomicilios.WithSpecification(new DireccionPorDocumentoSpecification(idDocumento, tipoDireccion)) + return await _context.admDomicilios.WithSpecification(new DireccionPorDocumentoSpecification(idDocumento, tipoDireccion)) .ProjectTo(_mapper.ConfigurationProvider) - .FirstOrDefault(); + .FirstOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorId(int idDireccion) + public async Task BuscarPorIdAsync(int idDireccion, CancellationToken cancellationToken) { - return _context.admDomicilios.WithSpecification(new DireccionPorIdSpecification(idDireccion)) + return await _context.admDomicilios.WithSpecification(new DireccionPorIdSpecification(idDireccion)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public List TraerPorTipo(TipoCatalogoDireccion tipoCatalogoDireccion) + public async Task> TraerPorTipoAsync(TipoCatalogoDireccion tipoCatalogoDireccion, CancellationToken cancellationToken) { - return _context.admDomicilios.WithSpecification(new DireccionPorTipoCatalogoSpecification(tipoCatalogoDireccion)) + return await _context.admDomicilios.WithSpecification(new DireccionPorTipoCatalogoSpecification(tipoCatalogoDireccion)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerPorTipoYIdCatalogo(TipoCatalogoDireccion tipoCatalogoDireccion, int idCatalogo) + public async Task> TraerPorTipoYIdCatalogoAsync(TipoCatalogoDireccion tipoCatalogoDireccion, int idCatalogo, + CancellationToken cancellationToken) { - return _context.admDomicilios + return await _context.admDomicilios .WithSpecification(new DireccionPorTipoCatalogoYIdCatalogoSpecification(tipoCatalogoDireccion, idCatalogo)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerTodo() + public async Task> TraerTodoAsync(CancellationToken cancellationToken) { - return _context.admDomicilios.ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admDomicilios.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoModeloSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoModeloSqlRepository.cs index 3b257918..e42f733f 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoModeloSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoModeloSqlRepository.cs @@ -1,34 +1,17 @@ using System.Collections.Generic; using System.Linq; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; +using System.Threading; +using System.Threading.Tasks; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar documentos modelo. -/// -public sealed class DocumentoModeloSqlRepository : ContpaqiComercialSqlRepositoryBase, - IDocumentoModeloRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public DocumentoModeloSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public List TraerTodo() - { - return _context.admDocumentosModelo.ToList(); - } -} - /// /// Repositorio de SQL para consultar documentos modelo y transformarlos a un tipo destino utilizando AutoMapper. /// @@ -36,7 +19,7 @@ public List TraerTodo() /// Tipo del objecto destino al que se mapean los documentos modelo. /// public sealed class DocumentoModeloSqlRepository : ContpaqiComercialSqlRepositoryBase, - IDocumentoModeloRepository where T : class, new() + IDocumentoModeloSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -52,4 +35,10 @@ public List TraerTodo() { return _context.admDocumentosModelo.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admDocumentosModelo.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoSqlRepository.cs index b15097df..899303a3 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/DocumentoSqlRepository.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Models; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Clientes; @@ -12,51 +14,65 @@ using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Documentos; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; // ReSharper disable CompareOfFloatsByEqualityOperator namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; /// -/// Repositorio de SQL para consultar documentos. +/// Repositorio de SQL para consultar documentos y transformarlos a un tipo destino utilizando AutoMapper. /// -public sealed class DocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, IDocumentoRepository +/// +/// Tipo del objecto destino al que se mapean los documentos. +/// +public sealed class DocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, IDocumentoSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; + private readonly IMapper _mapper; - public DocumentoSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) + public DocumentoSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) { _context = context; + _mapper = mapper; } /// - public admDocumentos? BuscarPorId(int idDocumento) + public T? BuscarPorId(int idDocumento) { - return _context.admDocumentos.WithSpecification(new DocumentoPorIdSpecification(idDocumento)).SingleOrDefault(); + return _context.admDocumentos.WithSpecification(new DocumentoPorIdSpecification(idDocumento)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefault(); } /// - public admDocumentos? BuscarPorLlave(string codigoConcepto, string serie, double folio) + public T? BuscarPorLlave(string codigoConcepto, string serie, double folio) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefault() ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); return _context.admDocumentos.WithSpecification(new DocumentoPorLlaveSpecification(concepto.CIDCONCEPTODOCUMENTO, serie, folio)) + .ProjectTo(_mapper.ConfigurationProvider) .SingleOrDefault(); } /// - public admDocumentos? BuscarPorLlave(LlaveDocumento llaveDocumento) + public T? BuscarPorLlave(LlaveDocumento llaveDocumento) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(llaveDocumento.ConceptoCodigo)).SingleOrDefault() ?? - throw new ArgumentException($"El concepto con codigo {llaveDocumento.ConceptoCodigo} no existe.", + var concepto = + _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(llaveDocumento.ConceptoCodigo)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefault() ?? throw new ArgumentException($"El concepto con codigo {llaveDocumento.ConceptoCodigo} no existe.", nameof(llaveDocumento.ConceptoCodigo)); return _context.admDocumentos .WithSpecification( new DocumentoPorLlaveSpecification(concepto.CIDCONCEPTODOCUMENTO, llaveDocumento.Serie, llaveDocumento.Folio)) + .ProjectTo(_mapper.ConfigurationProvider) .SingleOrDefault(); } @@ -74,44 +90,53 @@ public LlaveDocumento BuscarSiguienteSerieYFolio(string codigoConcepto) } /// - public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, - string codigoConcepto, string codigoClienteProveedor) + public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, string codigoConcepto, + string codigoClienteProveedor) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefault() ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? - throw new ArgumentException($"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", + var cliente = + _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(c => new { c.CIDCLIENTEPROVEEDOR }) + .SingleOrDefault() ?? throw new ArgumentException($"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); return _context.admDocumentos .WithSpecification(new DocumentosPorRangoFechaYConceptoYClienteSpecification(fechaInicio, fechaFin, concepto.CIDCONCEPTODOCUMENTO, cliente.CIDCLIENTEPROVEEDOR)) + .ProjectTo(_mapper.ConfigurationProvider) .ToList(); } /// - public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, - string codigoConcepto, IEnumerable codigosClienteProveedor) + public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, string codigoConcepto, + IEnumerable codigosClienteProveedor) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefault() ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); - var documentos = new List(); + var documentos = new List(); foreach (string codigoClienteProveedor in codigosClienteProveedor) { - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? + var cliente = + _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(c => new { c.CIDCLIENTEPROVEEDOR }) + .SingleOrDefault() ?? throw new ArgumentException($"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); documentos.AddRange(_context.admDocumentos .WithSpecification(new DocumentosPorRangoFechaYConceptoYClienteSpecification(fechaInicio, fechaFin, concepto.CIDCONCEPTODOCUMENTO, cliente.CIDCLIENTEPROVEEDOR)) + .ProjectTo(_mapper.ConfigurationProvider) .ToList()); } @@ -119,128 +144,107 @@ public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProvee } /// - public List TraerTodo() - { - return _context.admDocumentos.ToList(); - } -} - -/// -/// Repositorio de SQL para consultar documentos y transformarlos a un tipo destino utilizando AutoMapper. -/// -/// -/// Tipo del objecto destino al que se mapean los documentos. -/// -public sealed class DocumentoSqlRepository : ContpaqiComercialSqlRepositoryBase, IDocumentoRepository - where T : class, new() -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - private readonly IMapper _mapper; - - public DocumentoSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) + public List TraerTodo() { - _context = context; - _mapper = mapper; + return _context.admDocumentos.ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public T? BuscarPorId(int idDocumento) + public async Task BuscarPorIdAsync(int idDocumento, CancellationToken cancellationToken) { - return _context.admDocumentos.WithSpecification(new DocumentoPorIdSpecification(idDocumento)) + return await _context.admDocumentos.WithSpecification(new DocumentoPorIdSpecification(idDocumento)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorLlave(string codigoConcepto, string serie, double folio) + public async Task BuscarPorLlaveAsync(string codigoConcepto, string serie, double folio, CancellationToken cancellationToken) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + await _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); - return _context.admDocumentos.WithSpecification(new DocumentoPorLlaveSpecification(concepto.CIDCONCEPTODOCUMENTO, serie, folio)) + return await _context.admDocumentos + .WithSpecification(new DocumentoPorLlaveSpecification(concepto.CIDCONCEPTODOCUMENTO, serie, folio)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorLlave(LlaveDocumento llaveDocumento) + public async Task BuscarPorLlaveAsync(LlaveDocumento llaveDocumento, CancellationToken cancellationToken) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(llaveDocumento.ConceptoCodigo)).SingleOrDefault() ?? - throw new ArgumentException($"El concepto con codigo {llaveDocumento.ConceptoCodigo} no existe.", - nameof(llaveDocumento.ConceptoCodigo)); + var concepto = + await _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(llaveDocumento.ConceptoCodigo)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException( + $"El concepto con codigo {llaveDocumento.ConceptoCodigo} no existe.", nameof(llaveDocumento.ConceptoCodigo)); - return _context.admDocumentos + return await _context.admDocumentos .WithSpecification( new DocumentoPorLlaveSpecification(concepto.CIDCONCEPTODOCUMENTO, llaveDocumento.Serie, llaveDocumento.Folio)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); - } - - /// - public LlaveDocumento BuscarSiguienteSerieYFolio(string codigoConcepto) - { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? - throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); - - return new LlaveDocumento - { - ConceptoCodigo = concepto.CCODIGOCONCEPTO, Serie = concepto.CSERIEPOROMISION, Folio = concepto.CNOFOLIO - }; + .SingleOrDefaultAsync(cancellationToken); } /// - public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, string codigoConcepto, - string codigoClienteProveedor) + public async Task> TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedorAsync(DateTime fechaInicio, DateTime fechaFin, + string codigoConcepto, string codigoClienteProveedor, CancellationToken cancellationToken) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + await _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? + var cliente = + await _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(c => new { c.CIDCLIENTEPROVEEDOR }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException($"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); - return _context.admDocumentos + return await _context.admDocumentos .WithSpecification(new DocumentosPorRangoFechaYConceptoYClienteSpecification(fechaInicio, fechaFin, concepto.CIDCONCEPTODOCUMENTO, cliente.CIDCLIENTEPROVEEDOR)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedor(DateTime fechaInicio, DateTime fechaFin, string codigoConcepto, - IEnumerable codigosClienteProveedor) + public async Task> TraerPorRangoFechaYCodigoConceptoYCodigoClienteProveedorAsync(DateTime fechaInicio, DateTime fechaFin, + string codigoConcepto, IEnumerable codigosClienteProveedor, CancellationToken cancellationToken) { - admConceptos concepto = - _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)).SingleOrDefault() ?? + var concepto = + await _context.admConceptos.WithSpecification(new ConceptoPorCodigoSpecification(codigoConcepto)) + .Select(c => new { c.CIDCONCEPTODOCUMENTO }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException($"El concepto con codigo {codigoConcepto} no existe.", nameof(codigoConcepto)); var documentos = new List(); foreach (string codigoClienteProveedor in codigosClienteProveedor) { - admClientes cliente = - _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)).SingleOrDefault() ?? - throw new ArgumentException($"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", - nameof(codigoClienteProveedor)); + var cliente = + await _context.admClientes.WithSpecification(new ClientePorCodigoSpecification(codigoClienteProveedor)) + .Select(c => new { c.CIDCLIENTEPROVEEDOR }) + .SingleOrDefaultAsync(cancellationToken) ?? throw new ArgumentException( + $"El cliente/proveedor con codigo {codigoClienteProveedor} no existe.", nameof(codigoClienteProveedor)); - documentos.AddRange(_context.admDocumentos + documentos.AddRange(await _context.admDocumentos .WithSpecification(new DocumentosPorRangoFechaYConceptoYClienteSpecification(fechaInicio, fechaFin, concepto.CIDCONCEPTODOCUMENTO, cliente.CIDCLIENTEPROVEEDOR)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList()); + .ToListAsync(cancellationToken)); } return documentos; } /// - public List TraerTodo() + public async Task> TraerTodoAsync(CancellationToken cancellationToken) { - return _context.admDocumentos.ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admDocumentos.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/EmpresaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/EmpresaSqlRepository.cs index d8bf1bd5..1d08709b 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/EmpresaSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/EmpresaSqlRepository.cs @@ -1,48 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Generales; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Empresas; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar empresas. -/// -public sealed class EmpresaSqlRepository : ContpaqiComercialSqlRepositoryBase, IEmpresaRepository -{ - private readonly ContpaqiComercialGeneralesDbContext _context; - - public EmpresaSqlRepository(ContpaqiComercialGeneralesDbContext context) : base(context) - { - _context = context; - } - - /// - public Empresas? BuscarPorNombre(string nombreEmpresa) - { - return _context.Empresas.WithSpecification(new EmpresaPorNombreSpecification(nombreEmpresa)).FirstOrDefault(); - } - - /// - public List TraerTodo() - { - return _context.Empresas.ToList(); - } -} - /// /// Repositorio de SQL para consultar empresas y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean las empresas. /// -public sealed class EmpresaSqlRepository : ContpaqiComercialSqlRepositoryBase, IEmpresaRepository where T : class, new() +public sealed class EmpresaSqlRepository : ContpaqiComercialSqlRepositoryBase, IEmpresaSqlRepository + where T : class, new() { private readonly ContpaqiComercialGeneralesDbContext _context; private readonly IMapper _mapper; @@ -66,4 +45,18 @@ public List TraerTodo() { return _context.Empresas.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorNombreAsync(string nombreEmpresa, CancellationToken cancellationToken) + { + return await _context.Empresas.WithSpecification(new EmpresaPorNombreSpecification(nombreEmpresa)) + .ProjectTo(_mapper.ConfigurationProvider) + .FirstOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.Empresas.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ExistenciasSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ExistenciasSqlRepository.cs index d59fbef3..3104bdde 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ExistenciasSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ExistenciasSqlRepository.cs @@ -1,8 +1,10 @@ using System; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Almacenes; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.CapasProducto; @@ -10,13 +12,14 @@ using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Productos; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.ProductosDetalles; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.ValoresCaracteristicas; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; /// /// Repositorio de SQL para consultar existencias de productos. /// -public sealed class ExistenciasSqlRepository : IExistenciasRepository +public sealed class ExistenciasSqlRepository : IExistenciasSqlRepository { private readonly ContpaqiComercialEmpresaDbContext _context; @@ -49,6 +52,26 @@ public double BuscaExistencias(string codigoProducto, string codigoAlmacen, Date return entradas - salidas; } + /// + public double BuscaExistenciasConCapas(string codigoProducto, string codigoAlmacen, string pedimento, string lote) + { + var producto = _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) + .Select(p => new { p.CIDPRODUCTO }) + .Single(); + + var almacen = _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) + .Select(a => new { a.CIDALMACEN }) + .Single(); + + var capas = _context.admCapasProducto + .WithSpecification( + new CapaPorProductoAlmacenPedimentoLoteSpecification(producto.CIDPRODUCTO, almacen.CIDALMACEN, pedimento, lote)) + .Select(c => new { c.CEXISTENCIA }) + .FirstOrDefault(); + + return capas?.CEXISTENCIA ?? 0; + } + /// public double BuscaExistenciasConCaracteristicas(string codigoProducto, string codigoAlmacen, DateOnly fecha, string abreviaturaValorCaracteristica1, string abreviaturaValorCaracteristica2, string abreviaturaValorCaracteristica3) @@ -113,22 +136,113 @@ public double BuscaExistenciasConCaracteristicas(string codigoProducto, string c } /// - public double BuscaExistenciasConCapas(string codigoProducto, string codigoAlmacen, string pedimento, string lote) + public async Task BuscaExistenciasAsync(string codigoProducto, string codigoAlmacen, DateOnly fecha, + CancellationToken cancellationToken) { - var producto = _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) + var fechaCorte = fecha.ToDateTime(TimeOnly.MinValue); + + var producto = await _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) .Select(p => new { p.CIDPRODUCTO }) - .Single(); + .SingleAsync(cancellationToken); - var almacen = _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) + var almacen = await _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) .Select(a => new { a.CIDALMACEN }) - .Single(); + .SingleAsync(cancellationToken); - var capas = _context.admCapasProducto + var movimientos = await _context.admMovimientos + .WithSpecification(new MovimientosParaCalculoExistenciasSpecification(producto.CIDPRODUCTO, almacen.CIDALMACEN, fechaCorte)) + .Select(m => new { m.CAFECTAEXISTENCIA, m.CUNIDADES }) + .ToListAsync(cancellationToken); + + double entradas = movimientos.Where(m => m.CAFECTAEXISTENCIA == 1).Sum(m => m.CUNIDADES); + double salidas = movimientos.Where(m => m.CAFECTAEXISTENCIA == 2).Sum(m => m.CUNIDADES); + + return entradas - salidas; + } + + /// + public async Task BuscaExistenciasConCapasAsync(string codigoProducto, string codigoAlmacen, string pedimento, string lote, + CancellationToken cancellationToken) + { + var producto = await _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) + .Select(p => new { p.CIDPRODUCTO }) + .SingleAsync(cancellationToken); + + var almacen = await _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) + .Select(a => new { a.CIDALMACEN }) + .SingleAsync(cancellationToken); + + var capas = await _context.admCapasProducto .WithSpecification( new CapaPorProductoAlmacenPedimentoLoteSpecification(producto.CIDPRODUCTO, almacen.CIDALMACEN, pedimento, lote)) .Select(c => new { c.CEXISTENCIA }) - .FirstOrDefault(); + .FirstOrDefaultAsync(cancellationToken); return capas?.CEXISTENCIA ?? 0; } + + /// + public async Task BuscaExistenciasConCaracteristicasAsync(string codigoProducto, string codigoAlmacen, DateOnly fecha, + string abreviaturaValorCaracteristica1, string abreviaturaValorCaracteristica2, string abreviaturaValorCaracteristica3, + CancellationToken cancellationToken) + { + var fechaCorte = fecha.ToDateTime(TimeOnly.MinValue); + + var producto = await _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) + .Select(p => new { p.CIDPRODUCTO, p.CIDPADRECARACTERISTICA1, p.CIDPADRECARACTERISTICA2, p.CIDPADRECARACTERISTICA3 }) + .SingleAsync(cancellationToken); + + var almacen = await _context.admAlmacenes.WithSpecification(new AlmacenPorCodigoSpecification(codigoAlmacen)) + .Select(a => new { a.CIDALMACEN }) + .SingleAsync(cancellationToken); + + admCaracteristicasValores? valor1 = await _context.admCaracteristicasValores + .WithSpecification(new ValorCaracteristicaPorCaracteristicaIdYAbreviatura(producto.CIDPADRECARACTERISTICA1, + abreviaturaValorCaracteristica1)) + .FirstOrDefaultAsync(cancellationToken); + admCaracteristicasValores? valor2 = await _context.admCaracteristicasValores + .WithSpecification(new ValorCaracteristicaPorCaracteristicaIdYAbreviatura(producto.CIDPADRECARACTERISTICA2, + abreviaturaValorCaracteristica2)) + .FirstOrDefaultAsync(cancellationToken); + admCaracteristicasValores? valor3 = await _context.admCaracteristicasValores + .WithSpecification(new ValorCaracteristicaPorCaracteristicaIdYAbreviatura(producto.CIDPADRECARACTERISTICA3, + abreviaturaValorCaracteristica3)) + .FirstOrDefaultAsync(cancellationToken); + + var movimientos = await _context.admMovimientos + .WithSpecification(new MovimientosParaCalculoExistenciasSpecification(producto.CIDPRODUCTO, almacen.CIDALMACEN, fechaCorte)) + .Select(m => new { m.CIDMOVIMIENTO, m.CAFECTAEXISTENCIA, m.CUNIDADES }) + .ToListAsync(cancellationToken); + + var entradas = 0.0; + var salidas = 0.0; + + foreach (var movimiento in movimientos) + { + var movimientoOculto = await _context.admMovimientos + .WithSpecification(new MovimientoOcultoPorOwnerIdSpecification(movimiento.CIDMOVIMIENTO)) + .Select(m => new { m.CIDPRODUCTO }) + .FirstAsync(cancellationToken); + + var productoDetalle = await _context.admProductosDetalles + .WithSpecification(new ProductoDetallePorId(movimientoOculto.CIDPRODUCTO)) + .Select(p => new { p.CIDVALORCARACTERISTICA1, p.CIDVALORCARACTERISTICA2, p.CIDVALORCARACTERISTICA3 }) + .FirstAsync(cancellationToken); + + if (productoDetalle.CIDVALORCARACTERISTICA1 == (valor1?.CIDVALORCARACTERISTICA ?? 0) && + productoDetalle.CIDVALORCARACTERISTICA2 == (valor2?.CIDVALORCARACTERISTICA ?? 0) && + productoDetalle.CIDVALORCARACTERISTICA3 == (valor3?.CIDVALORCARACTERISTICA ?? 0)) + switch (movimiento.CAFECTAEXISTENCIA) + { + case 1: + entradas += movimiento.CUNIDADES; + break; + case 2: + salidas += movimiento.CUNIDADES; + break; + } + } + + return entradas - salidas; + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MonedaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MonedaSqlRepository.cs index 0d5d1127..0aa89f19 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MonedaSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MonedaSqlRepository.cs @@ -1,54 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Monedas; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar monedas. -/// -public sealed class MonedaSqlRepository : ContpaqiComercialSqlRepositoryBase, IMonedaRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public MonedaSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admMonedas? BuscarPorId(int idMoneda) - { - return _context.admMonedas.WithSpecification(new MonedaPorIdSpecification(idMoneda)).SingleOrDefault(); - } - - /// - public admMonedas? BuscarPorNombre(string nombreMoneda) - { - return _context.admMonedas.WithSpecification(new MonedaPorNombreSpecification(nombreMoneda)).SingleOrDefault(); - } - - /// - public List TraerTodo() - { - return _context.admMonedas.ToList(); - } -} - /// /// Repositorio de SQL para consultar monedas y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean las monedas. /// -public sealed class MonedaSqlRepository : ContpaqiComercialSqlRepositoryBase, IMonedaRepository where T : class, new() +public sealed class MonedaSqlRepository : ContpaqiComercialSqlRepositoryBase, IMonedaSqlRepository + where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -80,4 +53,26 @@ public List TraerTodo() { return _context.admMonedas.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorIdAsync(int idMoneda, CancellationToken cancellationToken) + { + return await _context.admMonedas.WithSpecification(new MonedaPorIdSpecification(idMoneda)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorNombreAsync(string nombreMoneda, CancellationToken cancellationToken) + { + return await _context.admMonedas.WithSpecification(new MonedaPorNombreSpecification(nombreMoneda)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admMonedas.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MovimientoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MovimientoSqlRepository.cs index a924c612..749447b1 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MovimientoSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/MovimientoSqlRepository.cs @@ -1,54 +1,26 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Movimientos; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar movimientos. -/// -public sealed class MovimientoSqlRepository : ContpaqiComercialSqlRepositoryBase, IMovimientoRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public MovimientoSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admMovimientos? BuscarPorId(int idMovimiento) - { - return _context.admMovimientos.WithSpecification(new MovimientoPorIdSpecification(idMovimiento)).SingleOrDefault(); - } - - /// - public List TraerPorDocumentoId(int idDocumento) - { - return _context.admMovimientos.WithSpecification(new MovimientosPorDocumentoIdSpecification(idDocumento)).ToList(); - } - - /// - public List TraerTodo() - { - return _context.admMovimientos.ToList(); - } -} - /// /// Repositorio de SQL para consultar movimientos y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los movimientos. /// -public sealed class MovimientoSqlRepository : ContpaqiComercialSqlRepositoryBase, IMovimientoRepository +public sealed class MovimientoSqlRepository : ContpaqiComercialSqlRepositoryBase, IMovimientoSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; @@ -81,4 +53,26 @@ public List TraerTodo() { return _context.admMovimientos.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorIdAsync(int idMovimiento, CancellationToken cancellationToken) + { + return await _context.admMovimientos.WithSpecification(new MovimientoPorIdSpecification(idMovimiento)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerPorDocumentoIdAsync(int idDocumento, CancellationToken cancellationToken) + { + return await _context.admMovimientos.WithSpecification(new MovimientosPorDocumentoIdSpecification(idDocumento)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admMovimientos.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ParametrosSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ParametrosSqlRepository.cs index ab041de3..38337f1a 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ParametrosSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ParametrosSqlRepository.cs @@ -1,39 +1,23 @@ using System.Linq; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; +using System.Threading; +using System.Threading.Tasks; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar parámetros. -/// -public sealed class ParametrosSqlRepository : ContpaqiComercialSqlRepositoryBase, IParametrosRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public ParametrosSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admParametros Buscar() - { - return _context.admParametros.Single(); - } -} - /// /// Repositorio de SQL para consultar parámetros y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los parametros. /// -public sealed class ParametrosSqlRepository : ContpaqiComercialSqlRepositoryBase, IParametrosRepository +public sealed class ParametrosSqlRepository : ContpaqiComercialSqlRepositoryBase, IParametrosSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; @@ -50,4 +34,10 @@ public T Buscar() { return _context.admParametros.ProjectTo(_mapper.ConfigurationProvider).Single(); } + + /// + public async Task BuscarAsync(CancellationToken cancellationToken) + { + return await _context.admParametros.ProjectTo(_mapper.ConfigurationProvider).SingleAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ProductoSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ProductoSqlRepository.cs index 399e35b2..965b93c9 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ProductoSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ProductoSqlRepository.cs @@ -1,61 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Productos; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar productos. -/// -public sealed class ProductoSqlRepository : ContpaqiComercialSqlRepositoryBase, IProductoRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public ProductoSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admProductos? BuscarPorCodigo(string codigoProducto) - { - return _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)).SingleOrDefault(); - } - - /// - public admProductos? BuscarPorId(int idProducto) - { - return _context.admProductos.WithSpecification(new ProductoPorIdSpecification(idProducto)).SingleOrDefault(); - } - - /// - public List TraerPorTipo(TipoProducto tipoProducto) - { - return _context.admProductos.WithSpecification(new ProductosPorTipoSpecification(tipoProducto)).ToList(); - } - - /// - public List TraerTodo() - { - return _context.admProductos.ToList(); - } -} - /// /// Repositorio de SQL para consultar productos y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean los productos. /// -public sealed class ProductoSqlRepository : ContpaqiComercialSqlRepositoryBase, IProductoRepository +public sealed class ProductoSqlRepository : ContpaqiComercialSqlRepositoryBase, IProductoSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; @@ -96,4 +62,34 @@ public List TraerTodo() { return _context.admProductos.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorCodigoAsync(string codigoProducto, CancellationToken cancellationToken) + { + return await _context.admProductos.WithSpecification(new ProductoPorCodigoSpecification(codigoProducto)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorIdAsync(int idProducto, CancellationToken cancellationToken) + { + return await _context.admProductos.WithSpecification(new ProductoPorIdSpecification(idProducto)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerPorTipoAsync(TipoProducto tipoProducto, CancellationToken cancellationToken) + { + return await _context.admProductos.WithSpecification(new ProductosPorTipoSpecification(tipoProducto)) + .ProjectTo(_mapper.ConfigurationProvider) + .ToListAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admProductos.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/UnidadMedidaSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/UnidadMedidaSqlRepository.cs index 5e608943..47f7467b 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/UnidadMedidaSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/UnidadMedidaSqlRepository.cs @@ -1,56 +1,27 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.UnidadesMedida; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; -/// -/// Repositorio de SQL para consultar unidades de medida. -/// -public sealed class UnidadMedidaSqlRepository : ContpaqiComercialSqlRepositoryBase, - IUnidadMedidaRepository -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - - public UnidadMedidaSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) - { - _context = context; - } - - /// - public admUnidadesMedidaPeso? BuscarPorId(int idUnidad) - { - return _context.admUnidadesMedidaPeso.WithSpecification(new UnidadMedidaPorIdSpecification(idUnidad)).SingleOrDefault(); - } - - /// - public admUnidadesMedidaPeso? BuscarPorNombre(string nombreUnidad) - { - return _context.admUnidadesMedidaPeso.WithSpecification(new UnidadMedidaPorNombreSpecification(nombreUnidad)).SingleOrDefault(); - } - - /// - public List TraerTodo() - { - return _context.admUnidadesMedidaPeso.ToList(); - } -} - /// /// Repositorio de SQL para consultar unidades de medida y transformarlos a un tipo destino utilizando AutoMapper. /// /// /// Tipo del objecto destino al que se mapean las unidades de medida. /// -public sealed class UnidadMedidaSqlRepository : ContpaqiComercialSqlRepositoryBase, IUnidadMedidaRepository - where T : class, new() +public sealed class UnidadMedidaSqlRepository : ContpaqiComercialSqlRepositoryBase, + IUnidadMedidaSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; private readonly IMapper _mapper; @@ -82,4 +53,26 @@ public List TraerTodo() { return _context.admUnidadesMedidaPeso.ProjectTo(_mapper.ConfigurationProvider).ToList(); } + + /// + public async Task BuscarPorIdAsync(int idUnidad, CancellationToken cancellationToken) + { + return await _context.admUnidadesMedidaPeso.WithSpecification(new UnidadMedidaPorIdSpecification(idUnidad)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task BuscarPorNombreAsync(string nombreUnidad, CancellationToken cancellationToken) + { + return await _context.admUnidadesMedidaPeso.WithSpecification(new UnidadMedidaPorNombreSpecification(nombreUnidad)) + .ProjectTo(_mapper.ConfigurationProvider) + .SingleOrDefaultAsync(cancellationToken); + } + + /// + public async Task> TraerTodoAsync(CancellationToken cancellationToken) + { + return await _context.admUnidadesMedidaPeso.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); + } } diff --git a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ValorClasificacionSqlRepository.cs b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ValorClasificacionSqlRepository.cs index b03e2d87..88768fa3 100644 --- a/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ValorClasificacionSqlRepository.cs +++ b/src/ARSoftware.Contpaqi.Comercial.Sql/Repositories/ValorClasificacionSqlRepository.cs @@ -1,41 +1,51 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Ardalis.Specification.EntityFrameworkCore; using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Enums; -using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Repositories; using ARSoftware.Contpaqi.Comercial.Sql.Contexts; +using ARSoftware.Contpaqi.Comercial.Sql.Interfaces; using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa; using ARSoftware.Contpaqi.Comercial.Sql.Repositories.Common; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.Clasificaciones; using ARSoftware.Contpaqi.Comercial.Sql.Specifications.ValoresClasificacion; using AutoMapper; using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; namespace ARSoftware.Contpaqi.Comercial.Sql.Repositories; /// -/// Repositorio de SQL para consultar valores de clasificación. +/// Repositorio de SQL para consultar valores de clasificación y transformarlos a un tipo destino utilizando +/// AutoMapper. /// -public sealed class ValorClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, - IValorClasificacionRepository +/// +/// Tipo del objecto destino al que se mapean los valores de clasificación. +/// +public sealed class ValorClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, + IValorClasificacionSqlRepository where T : class, new() { private readonly ContpaqiComercialEmpresaDbContext _context; + private readonly IMapper _mapper; - public ValorClasificacionSqlRepository(ContpaqiComercialEmpresaDbContext context) : base(context) + public ValorClasificacionSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) { _context = context; + _mapper = mapper; } /// - public admClasificacionesValores? BuscarPorId(int idValorClasificacion) + public T? BuscarPorId(int idValorClasificacion) { return _context.admClasificacionesValores.WithSpecification(new ValorClasificacionPorIdSpecification(idValorClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) .SingleOrDefault(); } /// - public admClasificacionesValores? BuscarPorTipoClasificacionNumeroYCodigo(TipoClasificacion tipoClasificacion, - NumeroClasificacion numeroClasificacion, string codigoValorClasificacion) + public T? BuscarPorTipoClasificacionNumeroYCodigo(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, + string codigoValorClasificacion) { admClasificaciones clasificacion = _context.admClasificaciones .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) @@ -44,20 +54,21 @@ public ValorClasificacionSqlRepository(ContpaqiComercialEmpresaDbContext context return _context.admClasificacionesValores .WithSpecification( new ValorClasificacionPorClasificacionIdYCodigoSpecification(clasificacion.CIDCLASIFICACION, codigoValorClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) .SingleOrDefault(); } /// - public List TraerPorClasificacionId(int idClasificacion) + public List TraerPorClasificacionId(int idClasificacion) { return _context.admClasificacionesValores .WithSpecification(new ValoresClasificacionPorClasificacionIdSpecification(idClasificacion)) + .ProjectTo(_mapper.ConfigurationProvider) .ToList(); } /// - public List TraerPorClasificacionTipoYNumero(TipoClasificacion tipoClasificacion, - NumeroClasificacion numeroClasificacion) + public List TraerPorClasificacionTipoYNumero(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion) { admClasificaciones clasificacion = _context.admClasificaciones .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) @@ -65,83 +76,65 @@ public List TraerPorClasificacionTipoYNumero(TipoClas return _context.admClasificacionesValores .WithSpecification(new ValoresClasificacionPorClasificacionIdSpecification(clasificacion.CIDCLASIFICACION)) + .ProjectTo(_mapper.ConfigurationProvider) .ToList(); } /// - public List TraerTodo() - { - return _context.admClasificacionesValores.ToList(); - } -} - -/// -/// Repositorio de SQL para consultar valores de clasificación y transformarlos a un tipo destino utilizando -/// AutoMapper. -/// -/// -/// Tipo del objecto destino al que se mapean los valores de clasificación. -/// -public sealed class ValorClasificacionSqlRepository : ContpaqiComercialSqlRepositoryBase, - IValorClasificacionRepository where T : class, new() -{ - private readonly ContpaqiComercialEmpresaDbContext _context; - private readonly IMapper _mapper; - - public ValorClasificacionSqlRepository(ContpaqiComercialEmpresaDbContext context, IMapper mapper) : base(context, mapper) + public List TraerTodo() { - _context = context; - _mapper = mapper; + return _context.admClasificacionesValores.ProjectTo(_mapper.ConfigurationProvider).ToList(); } /// - public T? BuscarPorId(int idValorClasificacion) + public async Task BuscarPorIdAsync(int idValorClasificacion, CancellationToken cancellationToken) { - return _context.admClasificacionesValores.WithSpecification(new ValorClasificacionPorIdSpecification(idValorClasificacion)) + return await _context.admClasificacionesValores.WithSpecification(new ValorClasificacionPorIdSpecification(idValorClasificacion)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public T? BuscarPorTipoClasificacionNumeroYCodigo(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion, - string codigoValorClasificacion) + public async Task BuscarPorTipoClasificacionNumeroYCodigoAsync(TipoClasificacion tipoClasificacion, + NumeroClasificacion numeroClasificacion, string codigoValorClasificacion, CancellationToken cancellationToken) { - admClasificaciones clasificacion = _context.admClasificaciones + admClasificaciones clasificacion = await _context.admClasificaciones .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) - .Single(); + .SingleAsync(cancellationToken); - return _context.admClasificacionesValores + return await _context.admClasificacionesValores .WithSpecification( new ValorClasificacionPorClasificacionIdYCodigoSpecification(clasificacion.CIDCLASIFICACION, codigoValorClasificacion)) .ProjectTo(_mapper.ConfigurationProvider) - .SingleOrDefault(); + .SingleOrDefaultAsync(cancellationToken); } /// - public List TraerPorClasificacionId(int idClasificacion) + public async Task> TraerPorClasificacionIdAsync(int idClasificacion, CancellationToken cancellationToken) { - return _context.admClasificacionesValores + return await _context.admClasificacionesValores .WithSpecification(new ValoresClasificacionPorClasificacionIdSpecification(idClasificacion)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerPorClasificacionTipoYNumero(TipoClasificacion tipoClasificacion, NumeroClasificacion numeroClasificacion) + public async Task> TraerPorClasificacionTipoYNumeroAsync(TipoClasificacion tipoClasificacion, + NumeroClasificacion numeroClasificacion, CancellationToken cancellationToken) { - admClasificaciones clasificacion = _context.admClasificaciones + admClasificaciones clasificacion = await _context.admClasificaciones .WithSpecification(new ClasificacionPorTipoYNumeroSpecification(tipoClasificacion, numeroClasificacion)) - .Single(); + .SingleAsync(cancellationToken); - return _context.admClasificacionesValores + return await _context.admClasificacionesValores .WithSpecification(new ValoresClasificacionPorClasificacionIdSpecification(clasificacion.CIDCLASIFICACION)) .ProjectTo(_mapper.ConfigurationProvider) - .ToList(); + .ToListAsync(cancellationToken); } /// - public List TraerTodo() + public async Task> TraerTodoAsync(CancellationToken cancellationToken) { - return _context.admClasificacionesValores.ProjectTo(_mapper.ConfigurationProvider).ToList(); + return await _context.admClasificacionesValores.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(cancellationToken); } }