summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs84
1 files changed, 0 insertions, 84 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs
deleted file mode 100644
index e0e226c..0000000
--- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/PermissaoUsuarioRepository.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using AutoMapper;
-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.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;
-
-namespace Gestor.Infrastructure.Repository.Logic
-{
- public class PermissaoUsuarioRepository : GenericRepository<PermissaoUsuarioDb>, IPermissaoUsuarioRepository
- {
- private readonly GenericUnitOfWork _unitOfWork;
-
- public PermissaoUsuarioRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
- {
- this._unitOfWork = unitOfWork;
- }
-
- public PermissaoUsuario FindByPermissao(long id, TipoTela tela)
- {
- return this.Select(string.Format(" AND IdUsuario = {0} AND Tela = {1}", id, (int)tela)).FirstOrDefault<PermissaoUsuario>();
- }
-
- public List<PermissaoUsuario> FindByUsuario(long id)
- {
- return this.Select(string.Format(" AND IdUsuario = {0}", id));
- }
-
- public PermissaoUsuario Merge(PermissaoUsuario permissao)
- {
- PermissaoUsuarioDb permissaoUsuarioDb = ApplicationMapper.Mapper.Map<PermissaoUsuario, PermissaoUsuarioDb>(permissao);
- base.Merge(permissaoUsuarioDb);
- return ApplicationMapper.Mapper.Map<PermissaoUsuarioDb, PermissaoUsuario>(permissaoUsuarioDb);
- }
-
- public PermissaoUsuario SaveOrUpdate(PermissaoUsuario permissao)
- {
- PermissaoUsuarioDb permissaoUsuarioDb = ApplicationMapper.Mapper.Map<PermissaoUsuario, PermissaoUsuarioDb>(permissao);
- this.SaveOrUpdate(permissaoUsuarioDb);
- return ApplicationMapper.Mapper.Map<PermissaoUsuarioDb, PermissaoUsuario>(permissaoUsuarioDb);
- }
-
- private List<PermissaoUsuario> 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())
- {
- Auxiliar.CriarAuxiliarUsuario(sqlCommand);
- sqlCommand.CommandText = string.Concat("SELECT DISTINCT * FROM PermissaoUsuario WHERE 1=1 ", condition, ";");
- using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
- {
- sqlDataAdapter.SelectCommand = sqlCommand;
- sqlDataAdapter.Fill(dataTable);
- }
- }
- }
- return dataTable.MapPermissao();
- }
- }
-} \ No newline at end of file