From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Servicos/Seguros/SinistroServico.cs | 400 +++++++++++++++++++++ 1 file changed, 400 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs (limited to 'Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs') diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs new file mode 100644 index 0000000..19049b1 --- /dev/null +++ b/Codemerx/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> BuscarControles(long id) + { + int num = 3; + List controleSinistros1 = await Task.Run>(() => { + List 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(); + }); + return controleSinistros1; + } + + public async Task BuscarSinistro(long id) + { + int num = 3; + Sinistro sinistro1 = await Task.Run(() => { + 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> BuscarSinistro(Filtros filtro) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List 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(); + }); + return sinistros1; + } + + public async Task> BuscarSinistroPendente(Filtros filtro) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List 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(); + }); + return sinistros1; + } + + public async Task> BuscarSinistros(string numero) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List 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(); + }); + return sinistros1; + } + + public async Task Delete(Sinistro sinistro) + { + int num = 3; + base.Sucesso = true; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + 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 DeleteControle(ControleSinistro controle, bool atualizarItem) + { + int num = 3; + base.Sucesso = true; + bool flag1 = await Task.Run(async () => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + 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 Save(Sinistro sinistro, long idramo) + { + int num3 = 3; + base.Sucesso = true; + Sinistro sinistro1 = sinistro; + Funcoes.GetNetworkTime(); + Sinistro sinistro2 = await Task.Run(() => { + SinistroVida sinistroVida; + long num; + Sinistro sinistro3; + while (num3 > 0) + { + List registroLogs = new List(); + 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 -- cgit v1.2.3