From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../AgendaRepository.cs | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaRepository.cs (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaRepository.cs') diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaRepository.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaRepository.cs new file mode 100644 index 0000000..1ab42b8 --- /dev/null +++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaRepository.cs @@ -0,0 +1,86 @@ +using AutoMapper; +using Gestor.Infrastructure.Entities.Ferramentas; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +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 AgendaRepository : GenericRepository, IAgendaRepository, IGenericRepository + { + private readonly GenericUnitOfWork _unitOfWork; + + public AgendaRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) + { + this._unitOfWork = unitOfWork; + } + + public void Delete(long id) + { + AgendaDb agendaDb = base.FindEntityById(id); + if (agendaDb == null) + { + return; + } + (new AgendaEmailRepository(this._unitOfWork)).DeleteRange(id); + (new AgendaTelefoneRepository(this._unitOfWork)).DeleteRange(id); + base.Delete(agendaDb); + } + + public List Find(string filter) + { + AgendaRepository.u003cu003ec__DisplayClass3_0 variable = null; + IQueryable agendaDbs = base.All(); + ParameterExpression parameterExpression = Expression.Parameter(typeof(AgendaDb), "x"); + IQueryable agendaDbs1 = agendaDbs.Where(Expression.Lambda>(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(AgendaDb).GetMethod("get_Nome").MethodHandle)), (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(AgendaRepository.u003cu003ec__DisplayClass3_0)), FieldInfo.GetFieldFromHandle(typeof(AgendaRepository.u003cu003ec__DisplayClass3_0).GetField("filter").FieldHandle)) }), new ParameterExpression[] { parameterExpression })); + parameterExpression = Expression.Parameter(typeof(AgendaDb), "x"); + return agendaDbs1.Select(Expression.Lambda>(Expression.MemberInit(Expression.New(typeof(Agenda)), 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(Agenda).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(AgendaDb).GetMethod("get_Nome").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList(); + } + + public List Find() + { + List list = base.All().ToList(); + return ApplicationMapper.Mapper.Map, List>(list); + } + + public Agenda FindById(long id) + { + AgendaDb agendaDb = base.FindEntityById(id); + return ApplicationMapper.Mapper.Map(agendaDb); + } + + public List FindByName(string name) + { + AgendaRepository.u003cu003ec__DisplayClass4_0 variable = null; + IQueryable agendaDbs = base.All(); + ParameterExpression parameterExpression = Expression.Parameter(typeof(AgendaDb), "x"); + IQueryable agendaDbs1 = agendaDbs.Where(Expression.Lambda>(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(AgendaDb).GetMethod("get_Nome").MethodHandle)), (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(AgendaRepository.u003cu003ec__DisplayClass4_0)), FieldInfo.GetFieldFromHandle(typeof(AgendaRepository.u003cu003ec__DisplayClass4_0).GetField("name").FieldHandle)) }), new ParameterExpression[] { parameterExpression })).Take(150); + parameterExpression = Expression.Parameter(typeof(AgendaDb), "x"); + return agendaDbs1.Select(Expression.Lambda>(Expression.MemberInit(Expression.New(typeof(Agenda)), 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(Agenda).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(AgendaDb).GetMethod("get_Nome").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList(); + } + + public Agenda Merge(Agenda agenda) + { + AgendaDb agendaDb = ApplicationMapper.Mapper.Map(agenda); + base.Merge(agendaDb); + return ApplicationMapper.Mapper.Map(agendaDb); + } + + public Agenda SaveOrUpdate(Agenda agenda) + { + AgendaDb agendaDb = ApplicationMapper.Mapper.Map(agenda); + this.SaveOrUpdate(agendaDb); + return ApplicationMapper.Mapper.Map(agendaDb); + } + } +} \ No newline at end of file -- cgit v1.2.3