diff options
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs new file mode 100644 index 0000000..20fb507 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class InfoViewModel : BaseViewModel +{ + private ObservableCollection<Contato> _contatos = new ObservableCollection<Contato>(); + + private ObservableCollection<Item> _itens = new ObservableCollection<Item>(); + + private ObservableCollection<Parcela> _parcelas = new ObservableCollection<Parcela>(); + + private Documento _documento; + + private Visibility _ocultarInfos; + + private bool _carregando; + + public ObservableCollection<Contato> Contatos + { + get + { + return _contatos; + } + set + { + _contatos = value; + OnPropertyChanged("Contatos"); + } + } + + public ObservableCollection<Item> Itens + { + get + { + return _itens; + } + set + { + _itens = value; + OnPropertyChanged("Itens"); + } + } + + public ObservableCollection<Parcela> Parcelas + { + get + { + return _parcelas; + } + set + { + _parcelas = value; + OnPropertyChanged("Parcelas"); + } + } + + public Documento Documento + { + get + { + return _documento; + } + set + { + _documento = value; + OnPropertyChanged("Documento"); + } + } + + public Visibility OcultarInfos + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _ocultarInfos; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _ocultarInfos = value; + OnPropertyChanged("OcultarInfos"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public InfoViewModel(Documento documento, bool ocultarInfos) + { + Documento = documento; + OcultarInfos = (Visibility)(ocultarInfos ? 2 : 0); + Seleciona(); + } + + public async void Seleciona() + { + Carregando = true; + if (Documento != null) + { + Documento = await new ApoliceServico().BuscarApoliceAsync(((DomainBase)Documento).Id); + } + if ((int)OcultarInfos == 0 && Documento != null) + { + ObservableCollection<Parcela> observableCollection = await new ParcelaServico().BuscarParcelasAsync(((DomainBase)Documento).Id); + Parcelas = (((int)Documento.TipoRecebimento.GetValueOrDefault() == 2) ? new ObservableCollection<Parcela>(observableCollection.OrderByDescending((Parcela x) => x.VigenciaIncial)) : observableCollection); + } + Documento documento = Documento; + if (((documento != null) ? documento.Controle : null) != null) + { + Itens = await new ItemServico().BuscarItens(((DomainBase)Documento.Controle).Id, (StatusItem)0); + List<Contato> contatos = new List<Contato>(); + ClienteServico servico = new ClienteServico(); + if (Documento.Controle.Cliente != null) + { + ObservableCollection<ClienteTelefone> telefones = await servico.BuscarTelefonesAsync(((DomainBase)Documento.Controle.Cliente).Id); + ObservableCollection<ClienteEmail> observableCollection2 = await servico.BuscarEmailsAsync(((DomainBase)Documento.Controle.Cliente).Id); + if (telefones != null) + { + contatos.AddRange(((IEnumerable<ClienteTelefone>)telefones).Select((Func<ClienteTelefone, Contato>)((ClienteTelefone x) => new Contato + { + Tipo = (TipoContato)0, + TipoTelefone = ((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)1), + Numero = ((TelefoneBase)x).Prefixo + " " + ((TelefoneBase)x).Numero + })).Take(2).ToList()); + } + if (observableCollection2 != null) + { + contatos.AddRange(((IEnumerable<ClienteEmail>)observableCollection2).Select((Func<ClienteEmail, Contato>)((ClienteEmail x) => new Contato + { + Tipo = (TipoContato)1, + TipoTelefone = null, + Numero = ((EmailBase)x).Email + })).Take(1).ToList()); + } + } + Contatos = new ObservableCollection<Contato>(contatos); + } + Carregando = false; + } + + public string GerarObs(Documento doc) + { + if (doc.Tipo != 0) + { + return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}{Environment.NewLine}PROPOSTA DE ENDOSSO: {doc.PropostaEndosso}{Environment.NewLine}ENDOSSO: {doc.Endosso}"; + } + return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}"; + } +} |