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 --- .../ClienteEmailRepository.cs | 248 --------------------- 1 file changed, 248 deletions(-) delete mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteEmailRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteEmailRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteEmailRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteEmailRepository.cs deleted file mode 100644 index 6d40eff..0000000 --- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteEmailRepository.cs +++ /dev/null @@ -1,248 +0,0 @@ -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 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 ClienteEmailRepository : GenericRepository, IClienteEmailRepository, IGenericRepository - { - private readonly GenericUnitOfWork _unitOfWork; - - public ClienteEmailRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) - { - this._unitOfWork = unitOfWork; - } - - public void Delete(long id) - { - base.Delete(base.FindEntityById(id)); - } - - public List DeleteMail(long clienteId, List emails) - { - if (emails == null) - { - return null; - } - List list = ( - from x in base.All() - where x.Cliente.Id == clienteId - select x).ToList().Where((ClienteEmailDb email) => { - List clienteEmails = emails; - Func u003cu003e9_112 = ClienteEmailRepository.u003cu003ec.u003cu003e9__11_2; - if (u003cu003e9_112 == null) - { - u003cu003e9_112 = (ClienteEmail t) => t.Id; - ClienteEmailRepository.u003cu003ec.u003cu003e9__11_2 = u003cu003e9_112; - } - return !clienteEmails.Select(u003cu003e9_112).Contains(email.Id); - }).ToList(); - if (emails.Count == 0 && (list == null || list.Count == 0)) - { - return null; - } - ClienteEmailRepository clienteEmailRepository = this; - list.ForEach(new Action(clienteEmailRepository.Delete)); - return ApplicationMapper.Mapper.Map, List>(list); - } - - private List FindByCliente(long id) - { - return this.Select(string.Format(" AND cm.idcliente = {0}", id)); - } - - public List FindByCliente(List ids) - { - if (ids.Count == 0) - { - return new List(); - } - string str = string.Concat(" AND cm.idcliente IN (", string.Join(",", ids), ")"); - return this.Select(str); - } - - public List FindByClienteId(long id) - { - return this.FindByCliente(id); - } - - public ClienteEmail FindById(long id) - { - ClienteEmailDb clienteEmailDb = base.FindEntityById(id); - return ApplicationMapper.Mapper.Map(clienteEmailDb); - } - - public List FindEmailCliente(string email, long idempresa = 0L) - { - return this.Select((idempresa == 0 ? string.Concat(" AND cm.email LIKE '%", email, "%'") : string.Format(" AND c.idempresa = {0} AND CONTAINS(cm.email, \"%{1}%\")", idempresa, email))); - } - - public List Inserir(List emails, Cliente cliente) - { - emails.ForEach((ClienteEmail x) => { - string str; - x.Cliente = cliente; - ClienteEmail clienteEmail = x; - string observacao = x.Observacao; - if (observacao != null) - { - str = observacao.Trim(); - } - else - { - str = null; - } - clienteEmail.Observacao = str; - }); - List clienteEmailDbs = ApplicationMapper.Mapper.Map, List>(emails); - base.AddRange(clienteEmailDbs); - return ApplicationMapper.Mapper.Map, List>(clienteEmailDbs); - } - - public List Inserir(List emails) - { - List clienteEmailDbs = ApplicationMapper.Mapper.Map, List>(emails); - clienteEmailDbs.ForEach((ClienteEmailDb x) => { - string str; - ClienteEmailDb clienteEmailDb = x; - string observacao = x.Observacao; - if (observacao != null) - { - str = observacao.Trim(); - } - else - { - str = null; - } - clienteEmailDb.Observacao = str; - if (x.Id == 0) - { - this.SaveOrUpdate(x); - return; - } - base.Merge(x); - }); - return ApplicationMapper.Mapper.Map, List>(clienteEmailDbs); - } - - public ClienteEmail Merge(ClienteEmail clienteEmail) - { - string str; - ClienteEmailDb clienteEmailDb = ApplicationMapper.Mapper.Map(clienteEmail); - ClienteEmailDb clienteEmailDb1 = clienteEmailDb; - string observacao = clienteEmailDb.Observacao; - if (observacao != null) - { - str = observacao.Trim(); - } - else - { - str = null; - } - clienteEmailDb1.Observacao = str; - base.Merge(clienteEmailDb); - return ApplicationMapper.Mapper.Map(clienteEmailDb); - } - - public List Merge(List emails, Cliente cliente) - { - List clienteEmailDbs = ApplicationMapper.Mapper.Map, List>(emails); - clienteEmailDbs.ForEach((ClienteEmailDb x) => { - string str; - ClienteEmailDb clienteEmailDb = x; - string observacao = x.Observacao; - if (observacao != null) - { - str = observacao.Trim(); - } - else - { - str = null; - } - clienteEmailDb.Observacao = str; - if (x.Id != 0) - { - base.Merge(x); - return; - } - x.Cliente = ApplicationMapper.Mapper.Map(cliente); - this.SaveOrUpdate(x); - }); - return ApplicationMapper.Mapper.Map, List>(clienteEmailDbs); - } - - public ClienteEmail SaveOrUpdate(ClienteEmail clienteEmail) - { - string str; - ClienteEmailDb clienteEmailDb = ApplicationMapper.Mapper.Map(clienteEmail); - ClienteEmailDb clienteEmailDb1 = clienteEmailDb; - string observacao = clienteEmailDb.Observacao; - if (observacao != null) - { - str = observacao.Trim(); - } - else - { - str = null; - } - clienteEmailDb1.Observacao = str; - this.SaveOrUpdate(clienteEmailDb); - return ApplicationMapper.Mapper.Map(clienteEmailDb); - } - - private List Select(string condition) - { - object connection; - DataTable dataTable = 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()) - { - sqlCommand.CommandText = string.Concat("SELECT cm.idclimail AS Id, cm.idcliente as IdCliente, cm.email AS Email, cm.obs AS Observacao, cm.ordem AS Ordem, c.nome as NomeCliente FROM climail cm INNER JOIN cliente c ON c.idcliente = cm.idcliente WHERE 1=1 ", condition); - using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) - { - sqlDataAdapter.SelectCommand = sqlCommand; - sqlDataAdapter.Fill(dataTable); - } - } - } - List clienteEmails = CustomMap.MapEmail(dataTable); - int? nullable1 = new int?(0); - clienteEmails.ForEach((ClienteEmail x) => { - int? ordem = nullable1; - int? nullable = ordem; - nullable1 = (nullable.HasValue ? new int?(nullable.GetValueOrDefault() + 1) : null); - ClienteEmail clienteEmail = x; - ordem = x.Ordem; - clienteEmail.Ordem = (ordem.HasValue ? ordem : nullable1); - }); - return clienteEmails; - } - } -} \ No newline at end of file -- cgit v1.2.3