summaryrefslogtreecommitdiff
path: root/Gestor.Application/Servicos/Seguros/SinistroServico.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
commit674ca83ba9243a9e95a7568c797668dab6aee26a (patch)
tree4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/Servicos/Seguros/SinistroServico.cs
downloadgestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz
gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip
feat: upload files
Diffstat (limited to 'Gestor.Application/Servicos/Seguros/SinistroServico.cs')
-rw-r--r--Gestor.Application/Servicos/Seguros/SinistroServico.cs400
1 files changed, 400 insertions, 0 deletions
diff --git a/Gestor.Application/Servicos/Seguros/SinistroServico.cs b/Gestor.Application/Servicos/Seguros/SinistroServico.cs
new file mode 100644
index 0000000..19049b1
--- /dev/null
+++ b/Gestor.Application/Servicos/Seguros/SinistroServico.cs
@@ -0,0 +1,400 @@
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class SinistroServico : BaseServico
+ {
+ public SinistroServico()
+ {
+ }
+
+ internal async Task<List<ControleSinistro>> BuscarControles(long id)
+ {
+ int num = 3;
+ List<ControleSinistro> controleSinistros1 = await Task.Run<List<ControleSinistro>>(() => {
+ List<ControleSinistro> controleSinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controleSinistros = read.get_ControleSinistroRepository().FindByIdItem(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 48, num, id, true);
+ continue;
+ }
+ return controleSinistros;
+ }
+ return new List<ControleSinistro>();
+ });
+ return controleSinistros1;
+ }
+
+ public async Task<Sinistro> BuscarSinistro(long id)
+ {
+ int num = 3;
+ Sinistro sinistro1 = await Task.Run<Sinistro>(() => {
+ Sinistro sinistro;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistro = read.get_SinistroRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 49, num, id, true);
+ continue;
+ }
+ return sinistro;
+ }
+ return new Sinistro();
+ });
+ return sinistro1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistro(Filtros filtro)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindByData(filtro, false);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 176, num, filtro, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistroPendente(Filtros filtro)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindByData(filtro, true);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 176, num, filtro, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistros(string numero)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindNumeroSinistro(numero);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 177, num, numero, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<bool> Delete(Sinistro sinistro)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ registroLogs.Add(base.CreateLog(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2));
+ SinistroAuto sinistroAuto = commited.get_SinistroAutoRepository().FindBySinistroId(sinistro.get_Id());
+ SinistroVida sinistroVida = commited.get_SinistroVidaRepository().FindBySinistroId(sinistro.get_Id());
+ if (sinistroAuto != null)
+ {
+ commited.get_SinistroAutoRepository().Delete(sinistroAuto.get_Id());
+ }
+ if (sinistroVida != null)
+ {
+ commited.get_SinistroVidaRepository().Delete(sinistroVida.get_Id());
+ }
+ commited.get_SinistroRepository().Delete(sinistro.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 174, num, sinistro, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> DeleteControle(ControleSinistro controle, bool atualizarItem)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ bool flag1 = await Task.Run<bool>(async () => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (atualizarItem)
+ {
+ Item item = commited.get_ItemRepository().FindById(controle.get_Item().get_Id());
+ item.set_Sinistrado(false);
+ commited.get_ItemRepository().Merge(item);
+ }
+ foreach (Sinistro sinistro in commited.get_SinistroRepository().FindByControleId(controle.get_Id()))
+ {
+ registroLogs.Add(base.CreateLog(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2));
+ if (await this.Delete(sinistro))
+ {
+ continue;
+ }
+ flag = false;
+ return flag;
+ }
+ commited.get_ControleSinistroRepository().Delete(controle.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ return flag;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 174, num, controle, true);
+ }
+ registroLogs = null;
+ }
+ flag = false;
+ return flag;
+ });
+ return flag1;
+ }
+
+ public async Task<Sinistro> Save(Sinistro sinistro, long idramo)
+ {
+ int num3 = 3;
+ base.Sucesso = true;
+ Sinistro sinistro1 = sinistro;
+ Funcoes.GetNetworkTime();
+ Sinistro sinistro2 = await Task.Run<Sinistro>(() => {
+ SinistroVida sinistroVida;
+ long num;
+ Sinistro sinistro3;
+ while (num3 > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ Item item = commited.get_ItemRepository().FindById(sinistro.get_ControleSinistro().get_Item().get_Id());
+ item.set_Sinistrado(true);
+ sinistro1.get_ControleSinistro().set_Item(commited.get_ItemRepository().Merge(item));
+ bool id = sinistro1.get_ControleSinistro().get_Id() == (long)0;
+ SinistroAuto sinistroAuto = sinistro1.get_SinistroAuto();
+ sinistroVida = sinistro1.get_SinistroVida();
+ if (!id)
+ {
+ registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1, 7));
+ sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().Merge(sinistro1.get_ControleSinistro()));
+ sinistro1 = (sinistro1.get_Id() == 0 ? commited.get_SinistroRepository().SaveOrUpdate(sinistro1) : commited.get_SinistroRepository().Merge(sinistro1));
+ num = idramo;
+ long num1 = num - (long)5;
+ if (num1 <= (long)5)
+ {
+ switch ((uint)num1)
+ {
+ case 0:
+ {
+ goto Label0;
+ }
+ case 1:
+ case 2:
+ case 4:
+ case 5:
+ {
+ goto Label1;
+ }
+ case 3:
+ {
+ goto Label2;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)37)
+ {
+ goto Label3;
+ }
+ Label0:
+ if (sinistroAuto != null)
+ {
+ sinistroAuto.set_Sinistro(sinistro1);
+ sinistroAuto = (sinistroAuto.get_Id() == 0 ? commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto) : commited.get_SinistroAutoRepository().Merge(sinistroAuto));
+ sinistro1.set_SinistroAuto(sinistroAuto);
+ }
+ }
+ else
+ {
+ sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().SaveOrUpdate(sinistro1.get_ControleSinistro()));
+ sinistro1 = commited.get_SinistroRepository().SaveOrUpdate(sinistro1);
+ registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1.GetValorOriginal(), 7, 0));
+ num = idramo;
+ long num2 = num - (long)5;
+ if (num2 <= (long)5)
+ {
+ switch ((uint)num2)
+ {
+ case 0:
+ {
+ goto Label4;
+ }
+ case 1:
+ case 2:
+ case 4:
+ case 5:
+ {
+ goto Label5;
+ }
+ case 3:
+ {
+ goto Label2;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)37)
+ {
+ goto Label6;
+ }
+ Label4:
+ sinistroAuto.set_Sinistro(sinistro1);
+ sinistroAuto = commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto);
+ sinistro1.set_SinistroAuto(sinistroAuto);
+ }
+ Label2:
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ sinistro3 = sinistro1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num3 = base.Registrar(exception, 175, num3, sinistro, true);
+ continue;
+ }
+ return sinistro3;
+ }
+ return sinistro;
+ Label1:
+ if (sinistroVida == null)
+ {
+ sinistroVida = new SinistroVida();
+ }
+ sinistroVida.set_Sinistro(sinistro1);
+ sinistroVida = (sinistroVida.get_Id() == 0 ? commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida) : commited.get_SinistroVidaRepository().Merge(sinistroVida));
+ sinistro1.set_SinistroVida(sinistroVida);
+ goto Label2;
+ Label3:
+ if (num != (long)53)
+ {
+ goto Label2;
+ }
+ else
+ {
+ goto Label1;
+ }
+ Label5:
+ sinistroVida.set_Sinistro(sinistro1);
+ sinistroVida = commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida);
+ sinistro1.set_SinistroVida(sinistroVida);
+ goto Label2;
+ Label6:
+ if (num != (long)53)
+ {
+ goto Label2;
+ }
+ else
+ {
+ goto Label5;
+ }
+ });
+ return sinistro2;
+ }
+ }
+} \ No newline at end of file