diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
| commit | 674ca83ba9243a9e95a7568c797668dab6aee26a (patch) | |
| tree | 4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs | |
| download | gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip | |
feat: upload files
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs')
| -rw-r--r-- | Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs new file mode 100644 index 0000000..0e7d668 --- /dev/null +++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CredencialRepository.cs @@ -0,0 +1,75 @@ +using AutoMapper;
+using Gestor.Infrastructure.Entities.Ferramentas;
+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 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 CredencialRepository : GenericRepository<CredencialDb>, ICredencialRepository, IGenericRepository<CredencialDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public CredencialRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public void Delete(long id)
+ {
+ CredencialDb credencialDb = base.FindEntityById(id);
+ if (credencialDb == null)
+ {
+ return;
+ }
+ credencialDb.Excluido = true;
+ base.Merge(credencialDb);
+ }
+
+ public List<Credencial> Find(long idEmpresa)
+ {
+ List<CredencialDb> list = (
+ from x in base.All()
+ where x.IdEmpresa == idEmpresa && !x.Excluido
+ select x).ToList<CredencialDb>();
+ return ApplicationMapper.Mapper.Map<List<CredencialDb>, List<Credencial>>(list);
+ }
+
+ public List<Credencial> Find(string filter, long idEmpresa)
+ {
+ CredencialRepository.u003cu003ec__DisplayClass7_0 variable = null;
+ IQueryable<CredencialDb> credencialDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(CredencialDb), "x");
+ List<CredencialDb> list = credencialDbs.Where<CredencialDb>(Expression.Lambda<Func<CredencialDb, bool>>(Expression.AndAlso(Expression.Equal(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CredencialDb).GetMethod("get_Excluido").MethodHandle)), Expression.Constant(false, typeof(bool))), Expression.OrElse(Expression.OrElse(Expression.AndAlso(Expression.Equal(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CredencialDb).GetMethod("get_IdEmpresa").MethodHandle)), Expression.Field(Expression.Constant(variable, typeof(CredencialRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(CredencialRepository.u003cu003ec__DisplayClass7_0).GetField("idEmpresa").FieldHandle))), Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CredencialDb).GetMethod("get_Descricao").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(CredencialRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(CredencialRepository.u003cu003ec__DisplayClass7_0).GetField("filter").FieldHandle)) })), Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CredencialDb).GetMethod("get_Email").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(CredencialRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(CredencialRepository.u003cu003ec__DisplayClass7_0).GetField("filter").FieldHandle)) })), Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(CredencialDb).GetMethod("get_Dominio").MethodHandle)), (MethodInfo)MethodBase.GetMethodFromHandle(typeof(string).GetMethod("Contains", new Type[] { typeof(string) }).MethodHandle), new Expression[] { Expression.Field(Expression.Constant(variable, typeof(CredencialRepository.u003cu003ec__DisplayClass7_0)), FieldInfo.GetFieldFromHandle(typeof(CredencialRepository.u003cu003ec__DisplayClass7_0).GetField("filter").FieldHandle)) }))), new ParameterExpression[] { parameterExpression })).ToList<CredencialDb>();
+ return ApplicationMapper.Mapper.Map<List<CredencialDb>, List<Credencial>>(list);
+ }
+
+ public Credencial FindById(long id)
+ {
+ CredencialDb credencialDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<CredencialDb, Credencial>(credencialDb);
+ }
+
+ public Credencial Merge(Credencial credencial)
+ {
+ CredencialDb credencialDb = ApplicationMapper.Mapper.Map<Credencial, CredencialDb>(credencial);
+ base.Merge(credencialDb);
+ return ApplicationMapper.Mapper.Map<CredencialDb, Credencial>(credencialDb);
+ }
+
+ public Credencial SaveOrUpdate(Credencial credencial)
+ {
+ CredencialDb credencialDb = ApplicationMapper.Mapper.Map<Credencial, CredencialDb>(credencial);
+ this.SaveOrUpdate(credencialDb);
+ return ApplicationMapper.Mapper.Map<CredencialDb, Credencial>(credencialDb);
+ }
+ }
+}
\ No newline at end of file |