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/ProfissaoRepository.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProfissaoRepository.cs')
| -rw-r--r-- | Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProfissaoRepository.cs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProfissaoRepository.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProfissaoRepository.cs new file mode 100644 index 0000000..f251e6e --- /dev/null +++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProfissaoRepository.cs @@ -0,0 +1,92 @@ +using AutoMapper;
+using Gestor.Infrastructure.Entities.Common;
+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.Common;
+using Gestor.Model.Domain.Generic;
+using NHibernate;
+using NHibernate.Connection;
+using NHibernate.Impl;
+using System;
+using System.Collections.Generic;
+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 ProfissaoRepository : GenericRepository<ProfissaoDb>, IProfissaoRepository, IGenericRepository<ProfissaoDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public ProfissaoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public List<Profissao> Find(string filter)
+ {
+ ProfissaoRepository.u003cu003ec__DisplayClass5_0 variable = null;
+ IQueryable<ProfissaoDb> profissaoDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(ProfissaoDb), "x");
+ IQueryable<ProfissaoDb> profissaoDbs1 = profissaoDbs.Where<ProfissaoDb>(Expression.Lambda<Func<ProfissaoDb, bool>>(Expression.OrElse(Expression.Call(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProfissaoDb).GetMethod("get_Nome").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Trim").MethodHandle), Array.Empty<Expression>()), (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(ProfissaoRepository.u003cu003ec__DisplayClass5_0)), FieldInfo.GetFieldFromHandle(typeof(ProfissaoRepository.u003cu003ec__DisplayClass5_0).GetField("filter").FieldHandle)) }), Expression.Call(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProfissaoDb).GetMethod("get_Codigo").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Trim").MethodHandle), Array.Empty<Expression>()), (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(ProfissaoRepository.u003cu003ec__DisplayClass5_0)), FieldInfo.GetFieldFromHandle(typeof(ProfissaoRepository.u003cu003ec__DisplayClass5_0).GetField("filter").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
+ parameterExpression = Expression.Parameter(typeof(ProfissaoDb), "x");
+ return profissaoDbs1.Select<ProfissaoDb, Profissao>(Expression.Lambda<Func<ProfissaoDb, Profissao>>(Expression.MemberInit(Expression.New(typeof(Profissao)), 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(Profissao).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProfissaoDb).GetMethod("get_Nome").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Profissao).GetMethod("set_Codigo", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProfissaoDb).GetMethod("get_Codigo").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Profissao>();
+ }
+
+ public long FindLastId()
+ {
+ long num;
+ object connection;
+ SqlCommand sqlCommand;
+ SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl;
+ if (sessionFactory != null)
+ {
+ connection = sessionFactory.ConnectionProvider.GetConnection();
+ }
+ else
+ {
+ connection = null;
+ }
+ using (SqlConnection sqlConnection = connection as SqlConnection)
+ {
+ if (sqlConnection != null)
+ {
+ sqlCommand = sqlConnection.CreateCommand();
+ }
+ else
+ {
+ sqlCommand = null;
+ }
+ using (SqlCommand sqlCommand1 = sqlCommand)
+ {
+ sqlCommand1.CommandText = "SELECT MAX(idprofissao) as id FROM profissao";
+ SqlDataReader sqlDataReader = sqlCommand1.ExecuteReader();
+ sqlDataReader.Read();
+ object item = sqlDataReader["id"];
+ num = (sqlDataReader["id"] == null || sqlDataReader["id"].ToString() == "" || sqlDataReader["id"].ToString() == "{}" ? (long)0 : long.Parse(sqlDataReader["id"].ToString()));
+ }
+ }
+ return num;
+ }
+
+ public Profissao Merge(Profissao profissao)
+ {
+ ProfissaoDb profissaoDb = ApplicationMapper.Mapper.Map<Profissao, ProfissaoDb>(profissao);
+ base.Merge(profissaoDb);
+ return ApplicationMapper.Mapper.Map<ProfissaoDb, Profissao>(profissaoDb);
+ }
+
+ public Profissao SaveOrUpdate(Profissao profissao)
+ {
+ ProfissaoDb profissaoDb = ApplicationMapper.Mapper.Map<Profissao, ProfissaoDb>(profissao);
+ this.SaveOrUpdate(profissaoDb);
+ return ApplicationMapper.Mapper.Map<ProfissaoDb, Profissao>(profissaoDb);
+ }
+ }
+}
\ No newline at end of file |