diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.cs')
| -rw-r--r-- | Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.cs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.cs new file mode 100644 index 0000000..0eac8b3 --- /dev/null +++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/StatusRepository.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 StatusRepository : GenericRepository<StatusDb>, IStatusRepository, IGenericRepository<StatusDb>
+ {
+ private readonly GenericUnitOfWork _unitOfWork;
+
+ public StatusRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
+ {
+ this._unitOfWork = unitOfWork;
+ }
+
+ public void Delete(long id)
+ {
+ base.Delete(base.FindEntityById(id));
+ }
+
+ public List<Status> Find(string value)
+ {
+ StatusRepository.u003cu003ec__DisplayClass6_0 variable = null;
+ IQueryable<StatusDb> statusDbs = base.All();
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(StatusDb), "x");
+ IQueryable<StatusDb> statusDbs1 = statusDbs.Where<StatusDb>(Expression.Lambda<Func<StatusDb, bool>>(Expression.OrElse(Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(StatusDb).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(StatusRepository.u003cu003ec__DisplayClass6_0)), FieldInfo.GetFieldFromHandle(typeof(StatusRepository.u003cu003ec__DisplayClass6_0).GetField("value").FieldHandle)) }), Expression.Call(Expression.Call(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(StatusDb).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(StatusRepository.u003cu003ec__DisplayClass6_0)), FieldInfo.GetFieldFromHandle(typeof(StatusRepository.u003cu003ec__DisplayClass6_0).GetField("value").FieldHandle)) })), new ParameterExpression[] { parameterExpression }));
+ parameterExpression = Expression.Parameter(typeof(StatusDb), "x");
+ return statusDbs1.Select<StatusDb, Status>(Expression.Lambda<Func<StatusDb, Status>>(Expression.MemberInit(Expression.New(typeof(Status)), 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(Status).GetMethod("set_Nome", new Type[] { typeof(string) }).MethodHandle), Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(StatusDb).GetMethod("get_Nome").MethodHandle))) }), new ParameterExpression[] { parameterExpression })).ToList<Status>();
+ }
+
+ public List<Status> Find()
+ {
+ return (
+ from x in this._unitOfWork.Session.CreateQuery("from StatusDb").List<StatusDb>()
+ select new Status()
+ {
+ Id = x.Id,
+ Nome = x.Nome,
+ Ativo = x.Ativo
+ }).ToList<Status>();
+ }
+
+ public Status FindById(long id)
+ {
+ StatusDb statusDb = base.FindEntityById(id);
+ return ApplicationMapper.Mapper.Map<StatusDb, Status>(statusDb);
+ }
+
+ public Status Merge(Status status)
+ {
+ StatusDb statusDb = ApplicationMapper.Mapper.Map<Status, StatusDb>(status);
+ base.Merge(statusDb);
+ return ApplicationMapper.Mapper.Map<StatusDb, Status>(statusDb);
+ }
+
+ public Status SaveOrUpdate(Status status)
+ {
+ StatusDb statusDb = ApplicationMapper.Mapper.Map<Status, StatusDb>(status);
+ this.SaveOrUpdate(statusDb);
+ return ApplicationMapper.Mapper.Map<StatusDb, Status>(statusDb);
+ }
+ }
+}
\ No newline at end of file |