diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs')
| -rw-r--r-- | Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs new file mode 100644 index 0000000..004432a --- /dev/null +++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ImpostoRepository.cs @@ -0,0 +1,102 @@ +using AutoMapper;
+using Gestor.Infrastructure.Entities.Ferramentas;
+using Gestor.Infrastructure.Helpers;
+using Gestor.Infrastructure.Mappers;
+using Gestor.Infrastructure.Repository.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Model.Domain.Ferramentas;
+using NHibernate;
+using NHibernate.Connection;
+using NHibernate.Impl;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+using System.Data.SqlClient;
+
+namespace Gestor.Infrastructure.Repository.Logic
+{
+ public class ImpostoRepository : GenericRepository<ImpostoDb>, IImpostoRepository, IGenericRepository<ImpostoDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public ImpostoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public List<Imposto> DefaultSelect(bool? ativo)
+ {
+ string str;
+ if (!ativo.HasValue)
+ {
+ str = "";
+ }
+ else
+ {
+ str = (ativo.Value ? " AND Ativo = 1" : " AND Ativo = 0");
+ }
+ return this.Select(str);
+ }
+
+ public Imposto FindById(long id)
+ {
+ ImpostoDb impostoDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<ImpostoDb, Imposto>(impostoDb);
+ }
+
+ public List<Imposto> FindByRamo(long id)
+ {
+ return this.Select(string.Format(" AND idramo = {0}", id));
+ }
+
+ public List<Imposto> FindBySeguradora(long id)
+ {
+ return this.Select(string.Format(" AND idciaseg = {0}", id));
+ }
+
+ public Imposto Merge(Imposto imposto)
+ {
+ ImpostoDb impostoDb = ApplicationMapper.Mapper.Map<Imposto, ImpostoDb>(imposto);
+ base.Merge(impostoDb);
+ return ApplicationMapper.Mapper.Map<ImpostoDb, Imposto>(impostoDb);
+ }
+
+ public Imposto SaveOrUpdate(Imposto imposto)
+ {
+ ImpostoDb impostoDb = ApplicationMapper.Mapper.Map<Imposto, ImpostoDb>(imposto);
+ this.SaveOrUpdate(impostoDb);
+ return ApplicationMapper.Mapper.Map<ImpostoDb, Imposto>(impostoDb);
+ }
+
+ private List<Imposto> Select(string condition)
+ {
+ object connection;
+ DataTable dataTable = new DataTable();
+ SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl;
+ if (sessionFactory != null)
+ {
+ connection = sessionFactory.ConnectionProvider.GetConnection();
+ }
+ else
+ {
+ connection = null;
+ }
+ using (SqlConnection sqlConnection = connection as SqlConnection)
+ {
+ using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
+ {
+ Auxiliar.CriarAuxiliar(sqlCommand, false);
+ sqlCommand.CommandText = string.Concat("SELECT * FROM Imposto WHERE 1=1 ", condition);
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ }
+ }
+ return CustomMap.MapImposto(dataTable);
+ }
+ }
+}
\ No newline at end of file |