From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../CoberturaViewModel.cs | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs b/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs new file mode 100644 index 0000000..47f386d --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels; + +public class CoberturaViewModel : BaseSegurosViewModel +{ + private readonly ItemServico _itemServico; + + private Cobertura _selectedCobertura = new Cobertura(); + + private List _coberturasPadrao; + + private ObservableCollection _coberturas; + + private readonly IComparer _comparerCobertura = Comparer.Create(delegate(Cobertura item1, Cobertura item2) + { + if (((DomainBase)item1).Id > ((DomainBase)item2).Id) + { + return 1; + } + return (((DomainBase)item1).Id < ((DomainBase)item2).Id) ? (-1) : 0; + }); + + public Item Item { get; set; } + + public Ramo Ramo { get; set; } + + public Cobertura SelectedCobertura + { + get + { + return _selectedCobertura; + } + set + { + _selectedCobertura = value; + OnPropertyChanged("SelectedCobertura"); + } + } + + public List CoberturasPadrao + { + get + { + return _coberturasPadrao; + } + set + { + _coberturasPadrao = value; + OnPropertyChanged("CoberturasPadrao"); + } + } + + public ObservableCollection Coberturas + { + get + { + return _coberturas; + } + set + { + _coberturas = value; + OnPropertyChanged("Coberturas"); + } + } + + public CoberturaViewModel(Ramo ramo = null, Item item = null) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + Item = item ?? ConsultaViewModel.ItemSelecionado; + object obj = ramo; + if (obj == null) + { + Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado; + if (documentoSelecionado == null) + { + obj = null; + } + else + { + Controle controle = documentoSelecionado.Controle; + obj = ((controle != null) ? controle.Ramo : null); + } + } + Ramo = (Ramo)obj; + _itemServico = new ItemServico(); + } + + public async Task SelectionaCoberturas() + { + if (Ramo != null) + { + CoberturasPadrao = Recursos.Coberturas.Where((CoberturaPadrao x) => x.IdRamo == ((DomainBase)Ramo).Id).ToList(); + if (Item != null) + { + Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id); + } + } + } + + internal async Task> BuscarCobertura(string value) + { + return await Task.Run(() => CoberturasPadrao?.Where((CoberturaPadrao x) => ValidationHelper.RemoveDiacritics(x.Descricao.ToUpper().Trim()).Contains(value.ToUpper())).ToList()); + } + + public void AdicionaCobertura() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Expected O, but got Unknown + Cobertura val = new Cobertura + { + Item = Item + }; + ValidationHelper.AddSorted(Coberturas, val, _comparerCobertura); + SelectedCobertura = val; + } + + public async void ExcluirCobertura(Cobertura cobertura) + { + if (cobertura != null && await ShowMessage("DESEJA REALMENTE EXCLUIR A COBERTURA" + Environment.NewLine + "\"" + cobertura.Observacao + "\"?", "SIM", "NÃO")) + { + Coberturas.Remove(cobertura); + } + } + + public async Task> LimpaCoberturas() + { + bool flag = Coberturas != null && Coberturas.Any((Cobertura x) => x.Franquia == 0m && x.Lmi == 0m && x.Premio == 0m); + if (flag) + { + flag = await ShowMessage("DESEJA LIMPAR AS COBERTURAS SEM VALOR DE FRANQUIA, LMI E PRÊMIO?", "SIM", "NÃO"); + } + return (!flag) ? Coberturas?.ToList() : Coberturas?.Where((Cobertura x) => !string.IsNullOrEmpty(x.Observacao) && (x.Franquia != 0m || x.Lmi != 0m || x.Premio != 0m)).ToList(); + } + + public async Task CancelarAlteracao() + { + if (Item != null) + { + Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id); + } + } + + public void CarregaPadrao() + { + List list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func)((CoberturaPadrao x) => new Cobertura + { + CoberturaPadrao = x, + Observacao = x.Descricao + })).ToList(); + if (list != null) + { + Coberturas = new ObservableCollection(list); + } + } + + public ObservableCollection CarregaCoberturaPadrao() + { + List list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func)((CoberturaPadrao x) => new Cobertura + { + CoberturaPadrao = x, + Observacao = x.Descricao + })).ToList(); + return Coberturas = new ObservableCollection(list); + } +} -- cgit v1.2.3