summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs96
1 files changed, 0 insertions, 96 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs
deleted file mode 100644
index c72986f..0000000
--- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CentroRepository.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using AutoMapper;
-using Gestor.Infrastructure.Entities.Financeiro;
-using Gestor.Infrastructure.Entities.Generic;
-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 Gestor.Model.Domain.Generic;
-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 CentroRepository : GenericRepository<CentroDb>, ICentroRepository, IGenericRepository<CentroDb>
- {
- private readonly GenericUnitOfWork _unitOfWork;
-
- public CentroRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
- {
- this._unitOfWork = unitOfWork;
- }
-
- public List<Centro> Find(string filter)
- {
- CentroRepository.u003cu003ec__DisplayClass2_0 variable = null;
- IQueryable<CentroDb> centroDbs = base.All();
- ParameterExpression parameterExpression = Expression.Parameter(typeof(CentroDb), "x");
- IQueryable<CentroDb> centroDbs1 = centroDbs.Where<CentroDb>(Expression.Lambda<Func<CentroDb, bool>>(Expression.AndAlso(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CentroDb).GetMethod("get_Ativo").MethodHandle)), Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CentroDb).GetMethod("get_Descricao").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("ToUpper").MethodHandle), Array.Empty<Expression>()), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(CentroRepository.u003cu003ec__DisplayClass2_0)), FieldInfo.GetFieldFromHandle(typeof(CentroRepository.u003cu003ec__DisplayClass2_0).GetField("filter").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
- parameterExpression = Expression.Parameter(typeof(CentroDb), "x");
- return centroDbs1.Select<CentroDb, Centro>(Expression.Lambda<Func<CentroDb, Centro>>(Expression.MemberInit(Expression.New(typeof(Centro)), new MemberBinding[] { Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(DomainBase).GetMethod("set_Id", new Type[] { typeof(long) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(EntityBase).GetMethod("get_Id").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Centro).GetMethod("set_Descricao", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CentroDb).GetMethod("get_Descricao").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Centro).GetMethod("set_Ativo", new Type[] { typeof(bool) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CentroDb).GetMethod("get_Ativo").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Centro).GetMethod("set_IdEmpresa", new Type[] { typeof(long) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CentroDb).GetMethod("get_IdEmpresa").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Centro>();
- }
-
- public List<Centro> 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)
- {
- if (sqlConnection != null)
- {
- using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
- {
- sqlCommand.CommandText = "SELECT DISTINCT idcentro as id, descricao as nome, ativo FROM centro;";
- using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
- {
- sqlDataAdapter.SelectCommand = sqlCommand;
- sqlDataAdapter.Fill(dataTable);
- }
- }
- }
- }
- return (
- from a in dataTable.AsEnumerable().ToList<DataRow>()
- select new Centro()
- {
- Id = a.Field<long>("id"),
- Descricao = a.Field<string>("nome"),
- Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
- }).ToList<Centro>();
- }
-
- public Centro Merge(Centro centro)
- {
- CentroDb centroDb = ApplicationMapper.Mapper.Map<Centro, CentroDb>(centro);
- base.Merge(centroDb);
- return ApplicationMapper.Mapper.Map<CentroDb, Centro>(centroDb);
- }
-
- public Centro SaveOrUpdate(Centro centro)
- {
- CentroDb centroDb = ApplicationMapper.Mapper.Map<Centro, CentroDb>(centro);
- this.SaveOrUpdate(centroDb);
- return ApplicationMapper.Mapper.Map<CentroDb, Centro>(centroDb);
- }
- }
-} \ No newline at end of file