summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs112
1 files changed, 0 insertions, 112 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs
deleted file mode 100644
index 460e860..0000000
--- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/ClienteVinculoRepository.cs
+++ /dev/null
@@ -1,112 +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 System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-
-namespace Gestor.Infrastructure.Repository.Logic
-{
- public class ClienteVinculoRepository : GenericRepository<ClienteVinculoDb>, IClienteVinculoRepository, IGenericRepository<ClienteVinculoDb>
- {
- public ClienteVinculoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
- {
- }
-
- public void Delete(long id)
- {
- base.Delete(base.FindEntityById(id));
- }
-
- public List<ClienteVinculo> DeleteVinculo(long clienteId, List<ClienteVinculo> vinculos)
- {
- if (vinculos == null)
- {
- return null;
- }
- List<ClienteVinculoDb> list = (
- from x in base.All()
- where x.Cliente1.Id == clienteId || x.Cliente2.Id == clienteId
- select x).ToList<ClienteVinculoDb>().Where<ClienteVinculoDb>((ClienteVinculoDb vinculo) => {
- List<ClienteVinculo> clienteVinculos = vinculos;
- Func<ClienteVinculo, long> u003cu003e9_32 = ClienteVinculoRepository.u003cu003ec.u003cu003e9__3_2;
- if (u003cu003e9_32 == null)
- {
- u003cu003e9_32 = (ClienteVinculo t) => t.Id;
- ClienteVinculoRepository.u003cu003ec.u003cu003e9__3_2 = u003cu003e9_32;
- }
- return !clienteVinculos.Select<ClienteVinculo, long>(u003cu003e9_32).Contains<long>(vinculo.Id);
- }).ToList<ClienteVinculoDb>();
- ClienteVinculoRepository clienteVinculoRepository = this;
- list.ForEach(new Action<ClienteVinculoDb>(clienteVinculoRepository.Delete));
- return ApplicationMapper.Mapper.Map<List<ClienteVinculoDb>, List<ClienteVinculo>>(list);
- }
-
- public List<ClienteVinculo> FindByCliente(long id)
- {
- List<ClienteVinculoDb> list = (
- from x in base.All()
- where x.Cliente1.Id == id || x.Cliente2.Id == id
- select x).ToList<ClienteVinculoDb>();
- return ApplicationMapper.Mapper.Map<List<ClienteVinculoDb>, List<ClienteVinculo>>(list);
- }
-
- public ClienteVinculo FindById(long id)
- {
- ClienteVinculoDb clienteVinculoDb = base.FindEntityById(id);
- return ApplicationMapper.Mapper.Map<ClienteVinculoDb, ClienteVinculo>(clienteVinculoDb);
- }
-
- public List<ClienteVinculo> Inserir(List<ClienteVinculo> vinculos, Cliente cliente)
- {
- foreach (ClienteVinculo vinculo in vinculos)
- {
- if (vinculo.Cliente1.Id == cliente.Id || vinculo.Cliente1.Id == 0)
- {
- vinculo.Cliente1 = cliente;
- }
- else
- {
- if (vinculo.Cliente2.Id != cliente.Id && vinculo.Cliente2.Id != 0)
- {
- continue;
- }
- vinculo.Cliente2 = cliente;
- }
- }
- List<ClienteVinculoDb> clienteVinculoDbs = ApplicationMapper.Mapper.Map<List<ClienteVinculo>, List<ClienteVinculoDb>>(vinculos);
- base.AddRange(clienteVinculoDbs);
- return ApplicationMapper.Mapper.Map<List<ClienteVinculoDb>, List<ClienteVinculo>>(clienteVinculoDbs);
- }
-
- public List<ClienteVinculo> Merge(List<ClienteVinculo> vinculos, Cliente cliente)
- {
- List<ClienteVinculoDb> clienteVinculoDbs = ApplicationMapper.Mapper.Map<List<ClienteVinculo>, List<ClienteVinculoDb>>(vinculos);
- clienteVinculoDbs.ForEach((ClienteVinculoDb x) => {
- if (x.Id != 0)
- {
- base.Merge(x);
- return;
- }
- x.Cliente1 = ApplicationMapper.Mapper.Map<Cliente, ClienteDb>(cliente);
- this.SaveOrUpdate(x);
- });
- return ApplicationMapper.Mapper.Map<List<ClienteVinculoDb>, List<ClienteVinculo>>(clienteVinculoDbs);
- }
-
- public ClienteVinculo SaveOrUpdate(ClienteVinculo clienteVinculo)
- {
- ClienteVinculoDb clienteVinculoDb = ApplicationMapper.Mapper.Map<ClienteVinculo, ClienteVinculoDb>(clienteVinculo);
- this.SaveOrUpdate(clienteVinculoDb);
- return ApplicationMapper.Mapper.Map<ClienteVinculoDb, ClienteVinculo>(clienteVinculoDb);
- }
- }
-} \ No newline at end of file