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 --- .../MetaSeguradoraViewModel.cs | 212 +++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs new file mode 100644 index 0000000..4e162a9 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Assinador.Infrastructure.Helpers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class MetaSeguradoraViewModel : BaseSegurosViewModel +{ + private readonly MetaSeguradoraServico _servico; + + private readonly Seguradora _selectedSeguradora; + + private MetaSeguradora _selectedMetaSeguradora = new MetaSeguradora(); + + private ObservableCollection _metasSeguradora = new ObservableCollection(); + + private bool _carregando; + + public MetaSeguradora CancelMetaSeguradora; + + public MetaSeguradora SelectedMetaSeguradora + { + get + { + return _selectedMetaSeguradora; + } + set + { + _selectedMetaSeguradora = value; + CancelMetaSeguradora = ((value != null && ((DomainBase)value).Id > 0) ? value : CancelMetaSeguradora); + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedMetaSeguradora"); + } + } + + public ObservableCollection MetasSeguradora + { + get + { + return _metasSeguradora; + } + set + { + _metasSeguradora = value; + OnPropertyChanged("MetasSeguradora"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public MetaSeguradoraViewModel(Seguradora seguradora) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new MetaSeguradoraServico(); + Seleciona(seguradora); + _selectedSeguradora = seguradora; + } + + private async void Seleciona(Seguradora seguradora) + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)31); + await SelecionaMetasSeguradora(seguradora); + Loading(isLoading: false); + } + + public void SelecionaMetaSeguradora(MetaSeguradora metaSeguradora) + { + SelectedMetaSeguradora = metaSeguradora; + } + + private async Task SelecionaMetasSeguradora(Seguradora seguradora) + { + Carregando = true; + await CarregarMetas(seguradora); + if (MetasSeguradora.Count > 0) + { + SelecionaMetaSeguradora(MetasSeguradora.First()); + } + else + { + SelectedMetaSeguradora = new MetaSeguradora(); + Alterar(alterar: false); + base.EnableMenu = false; + base.EnableAlterar = false; + base.EnableExcluir = false; + } + Carregando = false; + } + + public void Incluir() + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Expected O, but got Unknown + DateTime date = Funcoes.GetNetworkTime().Date; + SelectedMetaSeguradora = new MetaSeguradora + { + Ano = date.Year, + Mes = (Mes)date.Month + }; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + SelectedMetaSeguradora.Seguradora = _selectedSeguradora; + string acao = ((((DomainBase)SelectedMetaSeguradora).Id == 0L) ? "INCLUIU" : "ALTEROU"); + MetaSeguradora value = await _servico.Save(SelectedMetaSeguradora); + if (!_servico.Sucesso) + { + return null; + } + RegistrarAcao(acao + " META DA SEGURADORA \"" + value.Seguradora.Nome + "\"", ((DomainBase)value).Id, (TipoTela)31, $"ID: {((DomainBase)value).Id}\nVALOR: {value.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)value.Mes)}\nANO: {value.Ano}"); + if (MetasSeguradora.Any((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id)) + { + DomainBase.Copy(MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value); + } + else + { + MetasSeguradora.Add(value); + } + MetasSeguradora = new ObservableCollection(MetasSeguradora); + SelectedMetaSeguradora = MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id); + Alterar(alterar: false); + return null; + } + + public async Task Excluir() + { + if (SelectedMetaSeguradora == null || ((DomainBase)SelectedMetaSeguradora).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedMetaSeguradora))) + { + Carregando = false; + Alterar(alterar: false); + return false; + } + MetaSeguradoraViewModel metaSeguradoraViewModel = this; + Seguradora seguradora = SelectedMetaSeguradora.Seguradora; + metaSeguradoraViewModel.RegistrarAcao("EXCLUIU META DA SEGURADORA \"" + ((seguradora != null) ? seguradora.Nome : null) + "\"", ((DomainBase)SelectedMetaSeguradora).Id, (TipoTela)31, $"ID: {((DomainBase)SelectedMetaSeguradora).Id}\nVALOR: {SelectedMetaSeguradora.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)SelectedMetaSeguradora.Mes)}\nANO: {SelectedMetaSeguradora.Ano}"); + int num = MetasSeguradora.IndexOf(SelectedMetaSeguradora); + MetasSeguradora.Remove(SelectedMetaSeguradora); + MetasSeguradora.Remove(SelectedMetaSeguradora); + MetasSeguradora = new ObservableCollection(MetasSeguradora); + if (MetasSeguradora.Count > 0) + { + SelectedMetaSeguradora = ((num < MetasSeguradora.Count) ? MetasSeguradora.ElementAt(num) : MetasSeguradora.Last()); + } + else + { + SelectedMetaSeguradora = new MetaSeguradora(); + Alterar(alterar: false); + base.EnableMenu = false; + base.EnableAlterar = false; + base.EnableExcluir = false; + } + Carregando = false; + return true; + } + + public void CancelarAlteracao() + { + Carregando = true; + if (CancelMetaSeguradora != null && MetasSeguradora.Any((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id)) + { + DomainBase.Copy(MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id), CancelMetaSeguradora); + SelectedMetaSeguradora = MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id); + } + Alterar(alterar: false); + Carregando = false; + } + + private async Task CarregarMetas(Seguradora seguradora) + { + MetasSeguradora = new ObservableCollection(from x in await new BaseServico().BuscarMetaSeguradoraAsync(seguradora) + orderby x.Mes, x.Valor + select x); + } +} -- cgit v1.2.3