From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../PlanosRepository.cs | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PlanosRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PlanosRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PlanosRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PlanosRepository.cs new file mode 100644 index 0000000..d76619d --- /dev/null +++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PlanosRepository.cs @@ -0,0 +1,101 @@ +using AutoMapper; +using Gestor.Infrastructure.Entities.Financeiro; +using Gestor.Infrastructure.Entities.Generic; +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.Financeiro; +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; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Gestor.Infrastructure.Repository.Logic +{ + public class PlanosRepository : GenericRepository, IPlanosRepository, IGenericRepository + { + private readonly GenericUnitOfWork _unitOfWork; + + public PlanosRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) + { + this._unitOfWork = unitOfWork; + } + + public List Find(string description) + { + PlanosRepository.u003cu003ec__DisplayClass3_0 variable = null; + IQueryable planosDbs = base.All(); + ParameterExpression parameterExpression = Expression.Parameter(typeof(PlanosDb), "x"); + List list = planosDbs.Where(Expression.Lambda>(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(PlanosDb).GetMethod("get_Descricao").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("ToUpper").MethodHandle), Array.Empty()), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(PlanosRepository.u003cu003ec__DisplayClass3_0)), FieldInfo.GetFieldFromHandle(typeof(PlanosRepository.u003cu003ec__DisplayClass3_0).GetField("description").FieldHandle)) }), new ParameterExpression[] { parameterExpression })).ToList(); + return ApplicationMapper.Mapper.Map, List>(list); + } + + public List Find() + { + object connection; + SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; + DataTable dataTable = new DataTable(); + if (sessionFactory != null) + { + connection = sessionFactory.ConnectionProvider.GetConnection(); + } + else + { + connection = null; + } + using (SqlConnection sqlConnection = connection as SqlConnection) + { + using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) + { + AuxiliarFinanceiro.Criar(sqlCommand); + sqlCommand.CommandText = "SELECT DISTINCT cs.idcplanos as id, cs.descricao as nome, cs.ativo, cs.idcplano, cs.idtipoconta, cs.ctipo, cp.descricao FROM cplanos cs INNER JOIN cplano cp ON cs.idcplano = cp.idcplano;"; + using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) + { + sqlDataAdapter.SelectCommand = sqlCommand; + sqlDataAdapter.Fill(dataTable); + } + } + } + return CustomMap.MapPlanos(dataTable); + } + + public Planos FindById(long id) + { + PlanosDb planosDb = base.FindEntityById(id); + return ApplicationMapper.Mapper.Map(planosDb); + } + + public List FindByPlanoId(long id) + { + List list = ( + from x in base.All() + where x.Plano.Id == id + select x).ToList(); + return ApplicationMapper.Mapper.Map, List>(list); + } + + public Planos Merge(Planos planos) + { + PlanosDb planosDb = ApplicationMapper.Mapper.Map(planos); + base.Merge(planosDb); + return ApplicationMapper.Mapper.Map(planosDb); + } + + public Planos SaveOrUpdate(Planos planos) + { + PlanosDb planosDb = ApplicationMapper.Mapper.Map(planos); + this.SaveOrUpdate(planosDb); + return ApplicationMapper.Mapper.Map(planosDb); + } + } +} \ No newline at end of file -- cgit v1.2.3