summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs
new file mode 100644
index 0000000..328fa86
--- /dev/null
+++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/SeguradoraRepository.cs
@@ -0,0 +1,76 @@
+using AutoMapper;
+using Gestor.Infrastructure.Entities.Generic;
+using Gestor.Infrastructure.Entities.Seguros;
+using Gestor.Infrastructure.Mappers;
+using Gestor.Infrastructure.Repository.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using NHibernate;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Repository.Logic
+{
+ public class SeguradoraRepository : GenericRepository<SeguradoraDb>, ISeguradoraRepository, IGenericRepository<SeguradoraDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public SeguradoraRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public void Delete(long id)
+ {
+ base.Delete(base.FindEntityById(id));
+ }
+
+ public List<Seguradora> Find(string filter)
+ {
+ SeguradoraRepository.u003cu003ec__DisplayClass3_0 variable = null;
+ IQueryable<SeguradoraDb> seguradoraDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(SeguradoraDb), "x");
+ IQueryable<SeguradoraDb> seguradoraDbs1 = seguradoraDbs.Where<SeguradoraDb>(Expression.Lambda<Func<SeguradoraDb, bool>>(Expression.OrElse(Expression.OrElse(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Nome").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(SeguradoraRepository.u003cu003ec__DisplayClass3_0)), FieldInfo.GetFieldFromHandle(typeof(SeguradoraRepository.u003cu003ec__DisplayClass3_0).GetField("filter").FieldHandle)) }), Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Documento").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(SeguradoraRepository.u003cu003ec__DisplayClass3_0)), FieldInfo.GetFieldFromHandle(typeof(SeguradoraRepository.u003cu003ec__DisplayClass3_0).GetField("filter").FieldHandle)) })), Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Susep").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(SeguradoraRepository.u003cu003ec__DisplayClass3_0)), FieldInfo.GetFieldFromHandle(typeof(SeguradoraRepository.u003cu003ec__DisplayClass3_0).GetField("filter").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
+ parameterExpression = Expression.Parameter(typeof(SeguradoraDb), "x");
+ return seguradoraDbs1.Select<SeguradoraDb, Seguradora>(Expression.Lambda<Func<SeguradoraDb, Seguradora>>(Expression.MemberInit(Expression.New(typeof(Seguradora)), 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(Seguradora).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Nome").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Seguradora).GetMethod("set_Documento", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Documento").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Seguradora).GetMethod("set_Susep", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(SeguradoraDb).GetMethod("get_Susep").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Seguradora>();
+ }
+
+ public List<Seguradora> Find(bool ativo)
+ {
+ List<SeguradoraDb> list = this._unitOfWork.Session.CreateQuery("from SeguradoraDb where ativo IS NULL OR ativo = '1'").List<SeguradoraDb>().ToList<SeguradoraDb>();
+ return ApplicationMapper.Mapper.Map<List<SeguradoraDb>, List<Seguradora>>(list);
+ }
+
+ public List<Seguradora> Find()
+ {
+ List<SeguradoraDb> list = base.All().ToList<SeguradoraDb>();
+ return ApplicationMapper.Mapper.Map<List<SeguradoraDb>, List<Seguradora>>(list);
+ }
+
+ public Seguradora FindById(long id)
+ {
+ SeguradoraDb seguradoraDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<SeguradoraDb, Seguradora>(seguradoraDb);
+ }
+
+ public Seguradora Merge(Seguradora seguradora)
+ {
+ SeguradoraDb seguradoraDb = ApplicationMapper.Mapper.Map<Seguradora, SeguradoraDb>(seguradora);
+ base.Merge(seguradoraDb);
+ return ApplicationMapper.Mapper.Map<SeguradoraDb, Seguradora>(seguradoraDb);
+ }
+
+ public Seguradora SaveOrUpdate(Seguradora seguradora)
+ {
+ SeguradoraDb seguradoraDb = ApplicationMapper.Mapper.Map<Seguradora, SeguradoraDb>(seguradora);
+ this.SaveOrUpdate(seguradoraDb);
+ return ApplicationMapper.Mapper.Map<SeguradoraDb, Seguradora>(seguradoraDb);
+ }
+ }
+} \ No newline at end of file