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 --- .../BancoRepository.cs | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/BancoRepository.cs') 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, IBancoRepository, IGenericRepository + { + 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 Find(string filter) + { + BancoRepository.u003cu003ec__DisplayClass7_0 variable = null; + IQueryable bancoDbs = base.All(); + ParameterExpression parameterExpression = Expression.Parameter(typeof(BancoDb), "x"); + IQueryable bancoDbs1 = bancoDbs.Where(Expression.Lambda>(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()), (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(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()), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Trim").MethodHandle), Array.Empty()), (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(Expression.Lambda>(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(); + } + + public Banco FindById(long id) + { + BancoDb bancoDb = base.FindEntityById(id); + return ApplicationMapper.Mapper.Map(bancoDb); + } + + public Banco Merge(Banco banco) + { + BancoDb bancoDb = ApplicationMapper.Mapper.Map(banco); + base.Merge(bancoDb); + return ApplicationMapper.Mapper.Map(bancoDb); + } + + public Banco SaveOrUpdate(Banco banco) + { + BancoDb bancoDb = ApplicationMapper.Mapper.Map(banco); + this.SaveOrUpdate(bancoDb); + return ApplicationMapper.Mapper.Map(bancoDb); + } + + public List SelectDefault() + { + return ApplicationMapper.Mapper.Map, List>(( + from x in base.All() + orderby x.Nome + select x).ToList()); + } + } +} \ No newline at end of file -- cgit v1.2.3