diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs new file mode 100644 index 0000000..d4633e7 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Servicos.Seguros; +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 ExpedicaoViewModel : BaseSegurosViewModel +{ + private readonly ExpedicaoServico _servico; + + private readonly Documento _documento; + + private bool _carregando; + + private Expedicao _selectedExpedicao = new Expedicao(); + + private ObservableCollection<Expedicao> _expedicoes = new ObservableCollection<Expedicao>(); + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public Expedicao SelectedExpedicao + { + get + { + return _selectedExpedicao; + } + set + { + _selectedExpedicao = value; + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedExpedicao"); + } + } + + public ObservableCollection<Expedicao> Expedicoes + { + get + { + return _expedicoes; + } + set + { + _expedicoes = value; + OnPropertyChanged("Expedicoes"); + } + } + + public ExpedicaoViewModel(Documento documento) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new ExpedicaoServico(); + _documento = documento; + Seleciona(documento); + } + + private async void Seleciona(Documento documento) + { + Carregando = true; + await PermissaoTela((TipoTela)46); + await Carregar(documento); + if (Expedicoes.Count > 0) + { + SelectedExpedicao = Expedicoes.First(); + } + else + { + SelectedExpedicao = new Expedicao(); + Alterar(alterar: false); + base.EnableMenu = false; + } + Carregando = false; + } + + private async Task Carregar(Documento documento) + { + Expedicoes = new ObservableCollection<Expedicao>(await _servico.BuscarExpedicoes(documento)); + } + + 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_0017: Expected O, but got Unknown + SelectedExpedicao = new Expedicao + { + Apolice = _documento + }; + Alterar(alterar: true); + } + + public async Task<List<KeyValuePair<string, string>>> Salvar() + { + SelectedExpedicao = await _servico.Save(SelectedExpedicao); + if (!_servico.Sucesso) + { + return null; + } + long id = ((DomainBase)SelectedExpedicao).Id; + await Carregar(SelectedExpedicao.Apolice); + SelectedExpedicao = ((IEnumerable<Expedicao>)Expedicoes).FirstOrDefault((Func<Expedicao, bool>)((Expedicao x) => ((DomainBase)x).Id == id)); + Alterar(alterar: false); + return null; + } + + public async void CancelarAlteracao() + { + Carregando = true; + long id = ((DomainBase)SelectedExpedicao).Id; + await Carregar(SelectedExpedicao.Apolice); + SelectedExpedicao = (Expedicao)((Expedicoes.Count > 0 && id > 0) ? ((IEnumerable<Expedicao>)Expedicoes).FirstOrDefault((Func<Expedicao, bool>)((Expedicao x) => ((DomainBase)x).Id == id)) : ((Expedicoes.Count > 0 && id == 0L) ? ((object)Expedicoes.First()) : ((object)new Expedicao()))); + Alterar(alterar: false); + Carregando = false; + } + + public async Task<bool> Excluir() + { + if (SelectedExpedicao == null || ((DomainBase)SelectedExpedicao).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedExpedicao))) + { + Carregando = false; + return false; + } + int num = Expedicoes.IndexOf(SelectedExpedicao); + Expedicoes.Remove(SelectedExpedicao); + if (Expedicoes.Count > 0) + { + SelectedExpedicao = ((num < Expedicoes.Count) ? Expedicoes.ElementAt(num) : Expedicoes.Last()); + } + else + { + SelectedExpedicao = new Expedicao(); + } + Carregando = false; + return true; + } +} |