From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Servicos/Ferramentas/StatusServico.cs | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Gestor.Application/Servicos/Ferramentas/StatusServico.cs (limited to 'Gestor.Application/Servicos/Ferramentas/StatusServico.cs') diff --git a/Gestor.Application/Servicos/Ferramentas/StatusServico.cs b/Gestor.Application/Servicos/Ferramentas/StatusServico.cs new file mode 100644 index 0000000..88b146c --- /dev/null +++ b/Gestor.Application/Servicos/Ferramentas/StatusServico.cs @@ -0,0 +1,124 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class StatusServico : BaseServico + { + public StatusServico() + { + } + + internal async Task BuscarStatusPorId(long id) + { + int num = 3; + Status statu1 = await Task.Run(() => { + Status statu; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + statu = read.get_StatusRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 119, num, id, true); + continue; + } + return statu; + } + return new Status(); + }); + return statu1; + } + + public async Task Delete(Status status) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status.GetValorOriginal(), 11, 2)); + commited.get_StatusRepository().Delete(status.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 221, num, status, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Status status) + { + int num = 3; + base.Sucesso = true; + Status statu1 = status; + Status statu2 = await Task.Run(() => { + Status statu; + bool flag; + List registroLogs = new List(); + status = statu1; + while (num > 0) + { + status = statu1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (status.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status, 11)); + } + status = (status.get_Id() == 0 ? commited.get_StatusRepository().SaveOrUpdate(status) : commited.get_StatusRepository().Merge(status)); + if (!flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status.GetValorOriginal(), 11, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + statu = status; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 227, num, status, true); + continue; + } + return statu; + } + return statu1; + }); + return statu2; + } + } +} \ No newline at end of file -- cgit v1.2.3