summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
commit674ca83ba9243a9e95a7568c797668dab6aee26a (patch)
tree4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs
downloadgestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz
gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip
feat: upload files
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.cs
new file mode 100644
index 0000000..472ec21
--- /dev/null
+++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ProdutoRepository.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 ProdutoRepository : GenericRepository<ProdutoDb>, IProdutoRepository, IGenericRepository<ProdutoDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public ProdutoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public void Delete(long id)
+ {
+ base.Delete(base.FindEntityById(id));
+ }
+
+ public List<Produto> Find(string value)
+ {
+ ProdutoRepository.u003cu003ec__DisplayClass6_0 variable = null;
+ IQueryable<ProdutoDb> produtoDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(ProdutoDb), "x");
+ IQueryable<ProdutoDb> produtoDbs1 = produtoDbs.Where<ProdutoDb>(Expression.Lambda<Func<ProdutoDb, bool>>(Expression.OrElse(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProdutoDb).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(ProdutoRepository.u003cu003ec__DisplayClass6_0)), FieldInfo.GetFieldFromHandle(typeof(ProdutoRepository.u003cu003ec__DisplayClass6_0).GetField("value").FieldHandle)) }), Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProdutoDb).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(ProdutoRepository.u003cu003ec__DisplayClass6_0)), FieldInfo.GetFieldFromHandle(typeof(ProdutoRepository.u003cu003ec__DisplayClass6_0).GetField("value").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
+ parameterExpression = Expression.Parameter(typeof(ProdutoDb), "x");
+ return produtoDbs1.Select<ProdutoDb, Produto>(Expression.Lambda<Func<ProdutoDb, Produto>>(Expression.MemberInit(Expression.New(typeof(Produto)), 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(Produto).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(ProdutoDb).GetMethod("get_Nome").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Produto>();
+ }
+
+ public List<Produto> Find()
+ {
+ return (
+ from x in this._unitOfWork.Session.CreateQuery("from ProdutoDb").List<ProdutoDb>()
+ select new Produto()
+ {
+ Id = x.Id,
+ Nome = x.Nome,
+ Ativo = x.Ativo
+ }).ToList<Produto>();
+ }
+
+ public Produto FindById(long id)
+ {
+ ProdutoDb produtoDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<ProdutoDb, Produto>(produtoDb);
+ }
+
+ public Produto Merge(Produto produto)
+ {
+ ProdutoDb produtoDb = ApplicationMapper.Mapper.Map<Produto, ProdutoDb>(produto);
+ base.Merge(produtoDb);
+ return ApplicationMapper.Mapper.Map<ProdutoDb, Produto>(produtoDb);
+ }
+
+ public Produto SaveOrUpdate(Produto produto)
+ {
+ ProdutoDb produtoDb = ApplicationMapper.Mapper.Map<Produto, ProdutoDb>(produto);
+ this.SaveOrUpdate(produtoDb);
+ return ApplicationMapper.Mapper.Map<ProdutoDb, Produto>(produtoDb);
+ }
+ }
+} \ No newline at end of file