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 --- .../ImpostoViewModel.cs | 314 +++++++++++++++++++++ 1 file changed, 314 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs new file mode 100644 index 0000000..a00c4be --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs @@ -0,0 +1,314 @@ +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.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ImpostoViewModel : BaseViewModel +{ + private bool _carregando; + + private bool _apelido; + + public int Tipo; + + private List _seguradoras; + + private List _ramos; + + private ObservableCollection _impostos = new ObservableCollection(); + + private Imposto _selectedImposto = new Imposto(); + + private Ramo _selectedRamo = new Ramo(); + + private Seguradora _selectedSeguradora = new Seguradora(); + + private ImpostoServico Servico { get; } + + public bool? Ativo { get; set; } = true; + + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + OnPropertyChanged("Carregando"); + } + } + + public bool Apelido + { + get + { + return _apelido; + } + set + { + _apelido = value; + OnPropertyChanged("Apelido"); + } + } + + public List Seguradoras + { + get + { + return _seguradoras; + } + set + { + _seguradoras = value; + OnPropertyChanged("Seguradoras"); + } + } + + public List Ramos + { + get + { + return _ramos; + } + set + { + _ramos = value; + OnPropertyChanged("Ramos"); + } + } + + public ObservableCollection Impostos + { + get + { + return _impostos; + } + set + { + _impostos = value; + OnPropertyChanged("Impostos"); + } + } + + public Imposto SelectedImposto + { + get + { + return _selectedImposto; + } + set + { + _selectedImposto = value; + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedImposto"); + } + } + + public Ramo SelectedRamo + { + get + { + return _selectedRamo; + } + set + { + _selectedRamo = value; + OnPropertyChanged("SelectedRamo"); + } + } + + public Seguradora SelectedSeguradora + { + get + { + return _selectedSeguradora; + } + set + { + _selectedSeguradora = value; + OnPropertyChanged("SelectedSeguradora"); + } + } + + public ImpostoViewModel() + { + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Expected O, but got Unknown + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Expected O, but got Unknown + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Expected O, but got Unknown + Servico = new ImpostoServico(); + Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6); + } + + public async Task Carregar(int tipo, long id) + { + Tipo = tipo; + await PermissaoTela((TipoTela)56); + List list = (from x in Recursos.Seguradoras + where x.Ativo || (tipo == 0 && ((DomainBase)x).Id == id) + orderby (!Apelido) ? x.Nome : x.NomeSocial + select x).ToList(); + list.Insert(0, new Seguradora + { + Nome = "TODAS SEGURADORAS", + NomeSocial = "TODAS SEGURADORAS", + Id = 0L + }); + Seguradoras = list; + SelectedSeguradora = Seguradoras.First(); + List list2 = (from x in Recursos.Ramos + where x.Ativo || (tipo == 1 && ((DomainBase)x).Id == id) + orderby x.Nome + select x).ToList(); + list2.Insert(0, new Ramo + { + Nome = "TODOS OS RAMOS", + Id = 0L + }); + Ramos = list2; + SelectedRamo = Ramos.First(); + string text = ((tipo == 1) ? ("O RAMO \"" + Ramos.First((Ramo x) => ((DomainBase)x).Id == id).Nome + "\"") : ("A SEGURADORA \"" + Seguradoras.First((Seguradora x) => ((DomainBase)x).Id == id).Nome + "\"")); + RegistrarAcao("ACESSOU IMPOSTOS D" + text, id, (TipoTela)56, $"ID: {id}"); + List source = await Servico.Buscar(true); + if (tipo != 1) + { + source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == id && x.Ramo == null).ToList(); + SelectedSeguradora = Seguradoras.Find((Seguradora x) => ((DomainBase)x).Id == id); + } + else + { + source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == id && x.Seguradora == null).ToList(); + SelectedRamo = Ramos.Find((Ramo x) => ((DomainBase)x).Id == id); + } + Impostos = new ObservableCollection(source.OrderByDescending((Imposto x) => x.Ativo)); + SelectedImposto = Impostos.FirstOrDefault(); + } + + public async Task Carregar(long id = 0L) + { + List source = await Servico.Buscar(Ativo); + if (((DomainBase)SelectedSeguradora).Id == 0L) + { + source = source.Where((Imposto x) => x.Seguradora == null).ToList(); + } + if (((DomainBase)SelectedSeguradora).Id > 0) + { + source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedSeguradora).Id).ToList(); + } + if (((DomainBase)SelectedRamo).Id == 0L) + { + source = source.Where((Imposto x) => x.Ramo == null).ToList(); + } + if (((DomainBase)SelectedRamo).Id > 0) + { + source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedRamo).Id).ToList(); + } + Impostos = new ObservableCollection(source.Where((Imposto x) => !Ativo.HasValue || x.Ativo == Ativo.Value).ToList()); + SelectedImposto = ((id == 0L) ? Impostos.FirstOrDefault() : ((IEnumerable)Impostos).FirstOrDefault((Func)((Imposto x) => ((DomainBase)x).Id == id))); + } + + public void Incluir() + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Expected O, but got Unknown + SelectedImposto = new Imposto + { + Seguradora = ((((DomainBase)SelectedSeguradora).Id > 0) ? SelectedSeguradora : null), + Ramo = ((((DomainBase)SelectedRamo).Id > 0) ? SelectedRamo : null), + Ativo = true + }; + Alterar(alterar: true); + } + + public void AlterarImposto() + { + Alterar(alterar: true); + } + + public async Task Cancelar() + { + Imposto selectedImposto = SelectedImposto; + long id = ((selectedImposto != null) ? ((DomainBase)selectedImposto).Id : 0); + Alterar(alterar: false); + await Carregar(id); + } + + public async Task>> Salvar() + { + List> list = SelectedImposto.Validate(); + list.AddRange(Validate(SelectedImposto)); + if (list.Count > 0) + { + return list; + } + string acao = ((((DomainBase)SelectedImposto).Id == 0L) ? "INCLUIU" : "ALTEROU"); + Imposto val = await Servico.Salvar(SelectedImposto); + if (!Servico.Sucesso) + { + return new List> + { + new KeyValuePair("GRAVAR", "HOUVE UM ERRO AO SALVAR O IMPOSTO SELECIONADO.") + }; + } + string text = ((val.Seguradora == null) ? "TODAS AS SEGURADORAS" : (" SEGURADORA " + val.Seguradora.Nome)); + string text2 = ((val.Ramo == null) ? "TODOS OS RAMOS" : (" RAMO " + val.Ramo.Nome)); + string text3 = " " + text + " E " + text2; + RegistrarAcao(acao + " IMPOSTO PARA " + text3, ((DomainBase)val).Id, (TipoTela)31, string.Format("ID: {0}{1}{2}\nSTATUS: {3}\nIR: {4:p2}\nISS: {5:p2}\nOUTROS: {6:p2}\nDESCONTO: {7:p2}", ((DomainBase)val).Id, text, text2, val.Ativo ? "ATIVO" : "INATIVO", val.Ir, val.Iss, val.Outros, val.Desconto)); + Alterar(alterar: false); + await Carregar(((DomainBase)val).Id); + return null; + } + + public List> Validate(Imposto imposto) + { + List> list = new List>(); + if (imposto == null) + { + return list; + } + if (imposto.Ativo && Impostos.Any(delegate(Imposto x) + { + if (((DomainBase)x).Id != ((DomainBase)imposto).Id) + { + Seguradora seguradora = x.Seguradora; + long? num = ((seguradora != null) ? new long?(((DomainBase)seguradora).Id) : null); + Seguradora seguradora2 = imposto.Seguradora; + if (num == ((seguradora2 != null) ? new long?(((DomainBase)seguradora2).Id) : null)) + { + Ramo ramo = x.Ramo; + long? num2 = ((ramo != null) ? new long?(((DomainBase)ramo).Id) : null); + Ramo ramo2 = imposto.Ramo; + if (num2 == ((ramo2 != null) ? new long?(((DomainBase)ramo2).Id) : null)) + { + return x.Ativo; + } + } + } + return false; + })) + { + list.Add(new KeyValuePair("IMPOSTO DUPLICADO", "NÃO É POSSIVEL INSERIR UM NOVO PARAMETRO DE IMPOSTO, POIS JÁ EXISTEM PARAMETROS PARA A MESMA SEGURADORA E RAMO")); + } + return list.Distinct().ToList(); + } +} -- cgit v1.2.3