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 --- .../ExtratoRepository.cs | 237 --------------------- 1 file changed, 237 deletions(-) delete mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ExtratoRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ExtratoRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ExtratoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ExtratoRepository.cs deleted file mode 100644 index ff4afc6..0000000 --- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ExtratoRepository.cs +++ /dev/null @@ -1,237 +0,0 @@ -using AutoMapper; -using Gestor.Infrastructure.Entities.Generic; -using Gestor.Infrastructure.Entities.Seguros; -using Gestor.Infrastructure.Helpers; -using Gestor.Infrastructure.Mappers; -using Gestor.Infrastructure.Repository.Generic; -using Gestor.Infrastructure.Repository.Interface; -using Gestor.Infrastructure.UnitOfWork.Generic; -using Gestor.Model.Common; -using Gestor.Model.Domain.Relatorios; -using Gestor.Model.Domain.Seguros; -using NHibernate; -using NHibernate.Connection; -using NHibernate.Impl; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Data.SqlClient; -using System.Linq; -using System.Linq.Expressions; -using System.Runtime.CompilerServices; - -namespace Gestor.Infrastructure.Repository.Logic -{ - public class ExtratoRepository : GenericRepository, IExtratoRepository, IGenericRepository - { - private readonly GenericUnitOfWork _unitOfWork; - - public ExtratoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) - { - this._unitOfWork = unitOfWork; - } - - public void Delete(long id) - { - List list = ( - from x in this._unitOfWork.Query() - where x.Extrato.Id == id - select x).ToList(); - if (list.Count > 0) - { - this._unitOfWork.Repository().DeleteRange(list); - } - ExtratoDb extratoDb = base.FindEntityById(id); - if (extratoDb == null) - { - return; - } - base.Delete(extratoDb); - } - - public List FindByData(Filtros filtro) - { - string str = "CAST(datacriacao AS DATE)"; - string referencia = filtro.Referencia; - if (referencia == "DATA DO EXTRATO") - { - str = "CAST(data AS DATE)"; - } - else if (referencia == "DATA DO CRÉDITO") - { - str = "CAST(DataCredito AS DATE)"; - } - List condicaos = new List() - { - new Condicao() - { - Campo = str, - Valores = filtro.Inicio.CriarValor(), - Operador = Operador.MaiorEIgual - }, - new Condicao() - { - Campo = str, - Valores = filtro.Fim.CriarValor(), - Operador = Operador.MenorEIgual - }, - new Condicao() - { - Campo = "idstatusextrato", - Valores = null, - Operador = Operador.Diferente, - Grupo = 1, - Operacao = Operacao.Or - }, - new Condicao() - { - Campo = "idstatusextrato", - Valores = "1".CriarValor(), - Operador = Operador.Diferente, - Grupo = 1, - Operacao = Operacao.Or - } - }; - return CustomMap.MapExtrato(this._unitOfWork.Select(condicaos.CreateParameters(0), "SELECT * FROM EXTRATO WHERE ", ""), null); - } - - public List FindByEmpresa(long id) - { - List list = ( - from x in base.All() - where x.IdEmpresa == id - select x).ToList(); - return ApplicationMapper.Mapper.Map, List>(list); - } - - public Extrato FindById(long id) - { - ExtratoDb extratoDb = base.FindEntityById(id); - return ApplicationMapper.Mapper.Map(extratoDb); - } - - public List FindBySeguradora(long id, long idusuario, long empresa, DateTime inicio, DateTime fim, StatusExtrato? status = null) - { - List extratos; - object connection; - DataTable dataTable = new DataTable(); - DataTable dataTable1 = new DataTable(); - SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; - if (sessionFactory != null) - { - connection = sessionFactory.ConnectionProvider.GetConnection(); - } - else - { - connection = null; - } - using (SqlConnection sqlConnection = connection as SqlConnection) - { - using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) - { - Auxiliar.CriarAuxiliar(sqlCommand, false); - string str = ""; - if (empresa > (long)1) - { - str = string.Format("idempresa = {0} AND", empresa); - } - string str1 = string.Format("SELECT * FROM EXTRATO WHERE {0} data >= '{1:yyyy-MM-dd}' AND data <= '{2:yyyy-MM-dd}'", str, inicio, fim); - if (id > (long)0) - { - str1 = string.Concat(str1, string.Format(" AND idciaseg = {0}", id)); - } - if (idusuario > (long)0) - { - str1 = string.Concat(str1, string.Format(" AND usuariocriacao = {0}", idusuario)); - } - if (status.HasValue) - { - StatusExtrato valueOrDefault = status.GetValueOrDefault(); - if (valueOrDefault == StatusExtrato.Pendente) - { - str1 = string.Concat(str1, " AND (idstatusextrato IS NULL OR idstatusextrato = 1)"); - } - else if (valueOrDefault == StatusExtrato.Baixado) - { - str1 = string.Concat(str1, " AND idstatusextrato IS NOT NULL AND idstatusextrato != 1"); - } - } - sqlCommand.CommandText = str1; - using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) - { - sqlDataAdapter.SelectCommand = sqlCommand; - sqlDataAdapter.Fill(dataTable); - } - if (dataTable.Rows.Count != 0) - { - string str2 = string.Concat(" AND idextrato IN (", string.Join(",", dataTable.AsEnumerable().Select((DataRow v) => v.Field("idextrato"))), ")"); - List nums = new List() - { - 13, - 1, - 10, - 5, - 12, - 6, - 8, - 21 - }; - sqlCommand.CommandText = string.Concat("SELECT idextrato, idparcelaextrato FROM parcelaextrato WHERE idstatusparcela NOT IN (", string.Join(",", - from v in nums - select v), ") ", str2); - using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter()) - { - sqlDataAdapter1.SelectCommand = sqlCommand; - sqlDataAdapter1.Fill(dataTable1); - return CustomMap.MapExtrato(dataTable, dataTable1); - } - } - else - { - extratos = new List(); - } - } - } - return extratos; - } - - public List FindByStatus(StatusExtrato status) - { - List list = ( - from x in base.All() - where (int)x.Status == (int)status - select x).ToList(); - return ApplicationMapper.Mapper.Map, List>(list); - } - - public List FindSeguradoras(StatusExtrato status) - { - return ( - from x in ( - from x in base.All() - where (int)x.Status == (int)status - select x.Seguradora).ToList() - group x by x.Id into x - select new Seguradora() - { - Id = x.Key, - Nome = x.First().Nome - }).ToList(); - } - - public Extrato Merge(Extrato extrato) - { - ExtratoDb extratoDb = ApplicationMapper.Mapper.Map(extrato); - base.Merge(extratoDb); - return ApplicationMapper.Mapper.Map(extratoDb); - } - - public Extrato SaveOrUpdate(Extrato extrato) - { - ExtratoDb extratoDb = ApplicationMapper.Mapper.Map(extrato); - this.SaveOrUpdate(extratoDb); - return ApplicationMapper.Mapper.Map(extratoDb); - } - } -} \ No newline at end of file -- cgit v1.2.3