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 --- .../RamoRepository.cs | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RamoRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RamoRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RamoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RamoRepository.cs new file mode 100644 index 0000000..563c6bf --- /dev/null +++ b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RamoRepository.cs @@ -0,0 +1,85 @@ +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.Seguros; +using NHibernate; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Gestor.Infrastructure.Repository.Logic +{ + public class RamoRepository : GenericRepository, IRamoRepository, IGenericRepository + { + private readonly GenericUnitOfWork _unitOfWork; + + public RamoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) + { + this._unitOfWork = unitOfWork; + } + + public void Delete(long id) + { + base.Delete(base.FindEntityById(id)); + } + + public List Find(bool ativo) + { + return ( + from x in this._unitOfWork.Session.CreateQuery("from RamoDb \r\n where ativo IS NULL OR ativo != '1'").List() + select new Ramo() + { + Id = x.Id, + Nome = x.Nome, + Iof = x.Iof, + Ativo = x.Ativo + }).ToList(); + } + + public List Find() + { + return ( + from x in this._unitOfWork.Session.CreateQuery("from RamoDb").List() + select new Ramo() + { + Id = x.Id, + Nome = x.Nome, + Iof = x.Iof, + Ativo = x.Ativo + }).ToList(); + } + + public Ramo FindById(long id) + { + RamoDb ramoDb = base.FindEntityById(id); + return ApplicationMapper.Mapper.Map(ramoDb); + } + + public Ramo Merge(Ramo ramo) + { + RamoDb ramoDb = ApplicationMapper.Mapper.Map(ramo); + base.Merge(ramoDb); + return ApplicationMapper.Mapper.Map(ramoDb); + } + + public List MergeRange(List ramos) + { + List ramoDbs = ApplicationMapper.Mapper.Map, List>(ramos); + RamoRepository ramoRepository = this; + ramoDbs.ForEach(new Action(ramoRepository.Merge)); + return ApplicationMapper.Mapper.Map, List>(ramoDbs); + } + + public Ramo SaveOrUpdate(Ramo ramo) + { + RamoDb ramoDb = ApplicationMapper.Mapper.Map(ramo); + this.SaveOrUpdate(ramoDb); + return ApplicationMapper.Mapper.Map(ramoDb); + } + } +} \ No newline at end of file -- cgit v1.2.3