1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
using AutoMapper;
using Gestor.Infrastructure.Entities.Relatorios;
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 System;
using System.Collections.Generic;
namespace Gestor.Infrastructure.Repository.Logic
{
public class ParametrosRelatorioRepository : GenericRepository<ParametrosRelatorioDb>, IParametrosRelatorioRepository, IGenericRepository<ParametrosRelatorioDb>
{
private readonly GenericUnitOfWork _unitOfWork;
public ParametrosRelatorioRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
{
this._unitOfWork = unitOfWork;
}
public void Delete(long id)
{
ParametrosRelatorioDb parametrosRelatorioDb = base.FindEntityById(id);
if (parametrosRelatorioDb == null)
{
return;
}
base.Delete(parametrosRelatorioDb);
}
public List<ParametrosRelatorio> Find(long id, Relatorio relatorio)
{
List<ParametrosRelatorio> parametrosRelatorios = this.Select(new List<Condicao>()
{
new Condicao()
{
Campo = "IdUsuario",
Valores = id.CriarValor<long>()
},
new Condicao()
{
Campo = "Relatorio",
Valores = relatorio.CriarValor<int>()
},
new Condicao()
{
Campo = "Header",
Valores = null,
Operador = Operador.Diferente
},
new Condicao()
{
Campo = "Header",
Valores = "".CriarValor<string>(),
Operador = Operador.Diferente
}
});
if (parametrosRelatorios.Count == 0)
{
parametrosRelatorios = this.Select(new List<Condicao>()
{
new Condicao()
{
Campo = "IdUsuario",
Valores = 0.CriarValor<int>()
},
new Condicao()
{
Campo = "Relatorio",
Valores = relatorio.CriarValor<int>()
},
new Condicao()
{
Campo = "Header",
Valores = null,
Operador = Operador.Diferente
},
new Condicao()
{
Campo = "Header",
Valores = "".CriarValor<string>(),
Operador = Operador.Diferente
}
});
}
return parametrosRelatorios;
}
public ParametrosRelatorio Merge(ParametrosRelatorio parametrosRelatorio)
{
ParametrosRelatorioDb parametrosRelatorioDb = ApplicationMapper.Mapper.Map<ParametrosRelatorio, ParametrosRelatorioDb>(parametrosRelatorio);
base.Merge(parametrosRelatorioDb);
return ApplicationMapper.Mapper.Map<ParametrosRelatorioDb, ParametrosRelatorio>(parametrosRelatorioDb);
}
public ParametrosRelatorio SaveOrUpdate(ParametrosRelatorio parametrosRelatorio)
{
ParametrosRelatorioDb parametrosRelatorioDb = ApplicationMapper.Mapper.Map<ParametrosRelatorio, ParametrosRelatorioDb>(parametrosRelatorio);
this.SaveOrUpdate(parametrosRelatorioDb);
return ApplicationMapper.Mapper.Map<ParametrosRelatorioDb, ParametrosRelatorio>(parametrosRelatorioDb);
}
public List<ParametrosRelatorio> Select(List<Condicao> condicao)
{
return this._unitOfWork.Select(condicao.CreateParameters(0), "SELECT * FROM CamposRelatorios WHERE ", "").MapCamposRelatorio();
}
}
}
|