summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs
new file mode 100644
index 0000000..eaba0c1
--- /dev/null
+++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs
@@ -0,0 +1,69 @@
+using AutoMapper;
+using Gestor.Infrastructure.Entities.Common;
+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 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 BancoRepository : GenericRepository<BancoDb>, IBancoRepository, IGenericRepository<BancoDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public BancoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public void Delete(long id)
+ {
+ base.Delete(base.FindEntityById(id));
+ }
+
+ public List<Banco> Find(string filter)
+ {
+ BancoRepository.u003cu003ec__DisplayClass7_0 variable = null;
+ IQueryable<BancoDb> bancoDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(BancoDb), "x");
+ IQueryable<BancoDb> bancoDbs1 = bancoDbs.Where<BancoDb>(Expression.Lambda<Func<BancoDb, bool>>(Expression.OrElse(Expression.Call(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(BancoDb).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(BancoRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(BancoRepository.u003cu003ec__DisplayClass7_0).GetField("filter").FieldHandle)) }), Expression.Call(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(BancoDb).GetMethod("get_Codigo").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(int).GetMethod("ToString").MethodHandle), Array.Empty<Expression>()), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Trim").MethodHandle), Array.Empty<Expression>()), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(BancoRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(BancoRepository.u003cu003ec__DisplayClass7_0).GetField("filter").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
+ parameterExpression = Expression.Parameter(typeof(BancoDb), "x");
+ return bancoDbs1.Select<BancoDb, Banco>(Expression.Lambda<Func<BancoDb, Banco>>(Expression.MemberInit(Expression.New(typeof(Banco)), new MemberBinding[] { Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Banco).GetMethod("set_Id", new Type[] { typeof(int) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(BancoDb).GetMethod("get_Id").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Banco).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(BancoDb).GetMethod("get_Nome").MethodHandle))), Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(typeof(Banco).GetMethod("set_Codigo", new Type[] { typeof(int) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(BancoDb).GetMethod("get_Codigo").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Banco>();
+ }
+
+ public Banco FindById(long id)
+ {
+ BancoDb bancoDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<BancoDb, Banco>(bancoDb);
+ }
+
+ public Banco Merge(Banco banco)
+ {
+ BancoDb bancoDb = ApplicationMapper.Mapper.Map<Banco, BancoDb>(banco);
+ base.Merge(bancoDb);
+ return ApplicationMapper.Mapper.Map<BancoDb, Banco>(bancoDb);
+ }
+
+ public Banco SaveOrUpdate(Banco banco)
+ {
+ BancoDb bancoDb = ApplicationMapper.Mapper.Map<Banco, BancoDb>(banco);
+ this.SaveOrUpdate(bancoDb);
+ return ApplicationMapper.Mapper.Map<BancoDb, Banco>(bancoDb);
+ }
+
+ public List<Banco> SelectDefault()
+ {
+ return ApplicationMapper.Mapper.Map<List<BancoDb>, List<Banco>>((
+ from x in base.All()
+ orderby x.Nome
+ select x).ToList<BancoDb>());
+ }
+ }
+} \ No newline at end of file