summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs149
1 files changed, 0 insertions, 149 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs
deleted file mode 100644
index 9c1b0d6..0000000
--- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AgendaTelefoneRepository.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-using AutoMapper;
-using Gestor.Infrastructure.Entities.Ferramentas;
-using Gestor.Infrastructure.Entities.Generic;
-using Gestor.Infrastructure.Mappers;
-using Gestor.Infrastructure.Repository.Generic;
-using Gestor.Infrastructure.Repository.Interface;
-using Gestor.Infrastructure.UnitOfWork.Generic;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Runtime.CompilerServices;
-
-namespace Gestor.Infrastructure.Repository.Logic
-{
- public class AgendaTelefoneRepository : GenericRepository<AgendaTelefoneDb>, IAgendaTelefoneRepository, IGenericRepository<AgendaTelefoneDb>
- {
- private readonly GenericUnitOfWork _unitOfWork;
-
- public AgendaTelefoneRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
- {
- this._unitOfWork = unitOfWork;
- }
-
- public void Delete(long id)
- {
- base.Delete(base.FindEntityById(id));
- }
-
- public void DeleteRange(long id)
- {
- IQueryable<AgendaTelefoneDb> agendaTelefoneDbs =
- from x in base.All()
- where x.Agenda.Id == id
- select x;
- if (!agendaTelefoneDbs.Any<AgendaTelefoneDb>())
- {
- return;
- }
- base.DeleteRange(agendaTelefoneDbs);
- }
-
- public List<AgendaTelefone> Find(string telefone)
- {
- List<AgendaTelefoneDb> list = (
- from x in base.All()
- where x.Numero.Contains(telefone)
- select x).ToList<AgendaTelefoneDb>();
- return ApplicationMapper.Mapper.Map<List<AgendaTelefoneDb>, List<AgendaTelefone>>(list);
- }
-
- private List<AgendaTelefone> FindByAgenda(long id)
- {
- return (
- from x in base.All()
- where x.Agenda.Id == id
- select new AgendaTelefone()
- {
- Id = x.Id,
- Agenda = ApplicationMapper.Mapper.Map<AgendaDb, Agenda>(x.Agenda),
- Prefixo = x.Prefixo,
- Numero = x.Numero,
- Tipo = x.Tipo,
- Observacao = x.Observacao
- }).ToList<AgendaTelefone>();
- }
-
- public List<AgendaTelefone> FindByAgendaId(long id)
- {
- return this.FindByAgenda(id);
- }
-
- public AgendaTelefone FindById(long id)
- {
- AgendaTelefoneDb agendaTelefoneDb = base.FindEntityById(id);
- return ApplicationMapper.Mapper.Map<AgendaTelefoneDb, AgendaTelefone>(agendaTelefoneDb);
- }
-
- public List<AgendaTelefone> Inserir(List<AgendaTelefone> telefones)
- {
- List<AgendaTelefoneDb> agendaTelefoneDbs = ApplicationMapper.Mapper.Map<List<AgendaTelefone>, List<AgendaTelefoneDb>>(telefones);
- agendaTelefoneDbs.ForEach((AgendaTelefoneDb x) => {
- if (x.Id == 0)
- {
- this.SaveOrUpdate(x);
- return;
- }
- base.Merge(x);
- });
- return ApplicationMapper.Mapper.Map<List<AgendaTelefoneDb>, List<AgendaTelefone>>(agendaTelefoneDbs);
- }
-
- public List<AgendaTelefone> Inserir(List<AgendaTelefone> telefones, Agenda agenda)
- {
- telefones.ForEach((AgendaTelefone x) => x.Agenda = agenda);
- List<AgendaTelefoneDb> agendaTelefoneDbs = ApplicationMapper.Mapper.Map<List<AgendaTelefone>, List<AgendaTelefoneDb>>(telefones);
- base.AddRange(agendaTelefoneDbs);
- return ApplicationMapper.Mapper.Map<List<AgendaTelefoneDb>, List<AgendaTelefone>>(agendaTelefoneDbs);
- }
-
- public AgendaTelefone Merge(AgendaTelefone telefone)
- {
- AgendaTelefoneDb agendaTelefoneDb = ApplicationMapper.Mapper.Map<AgendaTelefone, AgendaTelefoneDb>(telefone);
- base.Merge(agendaTelefoneDb);
- return ApplicationMapper.Mapper.Map<AgendaTelefoneDb, AgendaTelefone>(agendaTelefoneDb);
- }
-
- public List<AgendaTelefone> Merge(List<AgendaTelefone> telefones, Agenda agenda)
- {
- IQueryable<AgendaTelefoneDb> agendaTelefoneDbs =
- from x in base.All()
- where x.Agenda.Id == agenda.Id
- select x;
- AgendaTelefoneRepository agendaTelefoneRepository = this;
- (
- from x in agendaTelefoneDbs
- select x.Id).ToList<long>().Where<long>((long x) => {
- List<AgendaTelefone> agendaTelefones = telefones;
- Func<AgendaTelefone, long> u003cu003e9_114 = AgendaTelefoneRepository.u003cu003ec.u003cu003e9__11_4;
- if (u003cu003e9_114 == null)
- {
- u003cu003e9_114 = (AgendaTelefone t) => t.Id;
- AgendaTelefoneRepository.u003cu003ec.u003cu003e9__11_4 = u003cu003e9_114;
- }
- return !agendaTelefones.Select<AgendaTelefone, long>(u003cu003e9_114).Contains<long>(x);
- }).ToList<long>().ForEach(new Action<long>(agendaTelefoneRepository.Delete));
- List<AgendaTelefoneDb> agendaTelefoneDbs1 = ApplicationMapper.Mapper.Map<List<AgendaTelefone>, List<AgendaTelefoneDb>>(telefones);
- agendaTelefoneDbs1.ForEach((AgendaTelefoneDb x) => {
- if (x.Id != 0)
- {
- base.Merge(x);
- return;
- }
- x.Agenda = ApplicationMapper.Mapper.Map<Agenda, AgendaDb>(agenda);
- this.SaveOrUpdate(x);
- });
- return ApplicationMapper.Mapper.Map<List<AgendaTelefoneDb>, List<AgendaTelefone>>(agendaTelefoneDbs1);
- }
-
- public AgendaTelefone SaveOrUpdate(AgendaTelefone telefone)
- {
- AgendaTelefoneDb agendaTelefoneDb = ApplicationMapper.Mapper.Map<AgendaTelefone, AgendaTelefoneDb>(telefone);
- this.SaveOrUpdate(agendaTelefoneDb);
- return ApplicationMapper.Mapper.Map<AgendaTelefoneDb, AgendaTelefone>(agendaTelefoneDb);
- }
- }
-} \ No newline at end of file