summaryrefslogtreecommitdiff
path: root/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs')
-rw-r--r--Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs174
1 files changed, 0 insertions, 174 deletions
diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs
deleted file mode 100644
index f50d4ee..0000000
--- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/CoberturaRepository.cs
+++ /dev/null
@@ -1,174 +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 CoberturaRepository : GenericRepository<CoberturaDb>, ICoberturaRepository, IGenericRepository<CoberturaDb>
- {
- private readonly GenericUnitOfWork _unitOfWork;
-
- public CoberturaRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
- {
- this._unitOfWork = unitOfWork;
- }
-
- public List<Cobertura> AddRange(List<Cobertura> coberturas)
- {
- List<CoberturaDb> coberturaDbs = ApplicationMapper.Mapper.Map<List<Cobertura>, List<CoberturaDb>>(coberturas);
- base.AddRange(coberturaDbs);
- return ApplicationMapper.Mapper.Map<List<CoberturaDb>, List<Cobertura>>(coberturaDbs);
- }
-
- public void Delete(long id)
- {
- CoberturaDb coberturaDb = base.FindEntityById(id);
- if (coberturaDb == null)
- {
- return;
- }
- base.Delete(coberturaDb);
- }
-
- public void DeletebyItem(long id)
- {
- object connection;
- 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.Format("DELETE FROM cobertura WHERE iditem = {0}", id);
- sqlCommand.ExecuteNonQuery();
- }
- }
- }
-
- public void DeleteRange(List<long> ids)
- {
- List<CoberturaDb> list = (
- from x in base.All()
- where ids.Contains(x.Item.Id)
- select x).ToList<CoberturaDb>();
- if (list.Count == 0)
- {
- return;
- }
- base.DeleteRange(list);
- }
-
- public Cobertura FindById(long id)
- {
- CoberturaDb coberturaDb = base.FindEntityById(id);
- return ApplicationMapper.Mapper.Map<CoberturaDb, Cobertura>(coberturaDb);
- }
-
- public List<Cobertura> FindByItemId(long id)
- {
- object connection;
- SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl;
- DataTable dataTable = new DataTable();
- DataTable dataTable1 = new DataTable();
- if (sessionFactory != null)
- {
- connection = sessionFactory.ConnectionProvider.GetConnection();
- }
- else
- {
- connection = null;
- }
- using (SqlConnection sqlConnection = connection as SqlConnection)
- {
- using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
- {
- sqlCommand.CommandText = "SELECT * FROM coberturapadrao;";
- using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
- {
- sqlDataAdapter.SelectCommand = sqlCommand;
- sqlDataAdapter.Fill(dataTable);
- }
- sqlCommand.CommandText = string.Format("SELECT * FROM cobertura WHERE iditem = {0}", id);
- using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter())
- {
- sqlDataAdapter1.SelectCommand = sqlCommand;
- sqlDataAdapter1.Fill(dataTable1);
- }
- }
- }
- List<CoberturaPadrao> list = (
- from x in dataTable.AsEnumerable().ToList<DataRow>()
- select new CoberturaPadrao()
- {
- Id = x.Field<long>("idcoberturapadrao"),
- IdRamo = (x.Field<object>("idramo") != null ? x.Field<long>("idramo") : (long)0),
- Descricao = x.Field<string>("descricao")
- }).ToList<CoberturaPadrao>();
- return dataTable1.AsEnumerable().ToList<DataRow>().Select<DataRow, Cobertura>((DataRow x) => {
- Cobertura cobertura = new Cobertura()
- {
- Id = x.Field<long>("idcobertura"),
- CoberturaPadrao = (x.Field<object>("idcoberturapadrao") == null ? null : list.FirstOrDefault<CoberturaPadrao>((CoberturaPadrao c) => c.Id == x.Field<long>("idcoberturapadrao"))),
- Item = new Item()
- {
- Id = x.Field<long>("iditem")
- }
- };
- decimal? nullable = x.Field<decimal?>("franquia");
- cobertura.Franquia = nullable.GetValueOrDefault();
- nullable = x.Field<decimal?>("premio");
- cobertura.Premio = nullable.GetValueOrDefault();
- nullable = x.Field<decimal?>("lmi");
- cobertura.Lmi = nullable.GetValueOrDefault();
- cobertura.Observacao = x.Field<string>("observacao");
- return cobertura;
- }).ToList<Cobertura>();
- }
-
- public Cobertura Merge(Cobertura cobertura)
- {
- CoberturaDb coberturaDb = ApplicationMapper.Mapper.Map<Cobertura, CoberturaDb>(cobertura);
- base.Merge(coberturaDb);
- return ApplicationMapper.Mapper.Map<CoberturaDb, Cobertura>(coberturaDb);
- }
-
- public List<Cobertura> MergeRange(List<Cobertura> coberturas)
- {
- List<CoberturaDb> coberturaDbs = ApplicationMapper.Mapper.Map<List<Cobertura>, List<CoberturaDb>>(coberturas);
- CoberturaRepository coberturaRepository = this;
- coberturaDbs.ForEach(new Action<CoberturaDb>(coberturaRepository.Merge));
- return ApplicationMapper.Mapper.Map<List<CoberturaDb>, List<Cobertura>>(coberturaDbs);
- }
-
- public Cobertura SaveOrUpdate(Cobertura cobertura)
- {
- CoberturaDb coberturaDb = ApplicationMapper.Mapper.Map<Cobertura, CoberturaDb>(cobertura);
- this.SaveOrUpdate(coberturaDb);
- return ApplicationMapper.Mapper.Map<CoberturaDb, Cobertura>(coberturaDb);
- }
- }
-} \ No newline at end of file