From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Drawer/InfoViewModel.cs | 208 +++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/InfoViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/Drawer/InfoViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/InfoViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/InfoViewModel.cs new file mode 100644 index 0000000..1352f12 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/InfoViewModel.cs @@ -0,0 +1,208 @@ +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; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; + +namespace Gestor.Application.ViewModels.Drawer +{ + public class InfoViewModel : BaseViewModel + { + private ObservableCollection _contatos = new ObservableCollection(); + + private ObservableCollection _itens = new ObservableCollection(); + + private ObservableCollection _parcelas = new ObservableCollection(); + + private Gestor.Model.Domain.Seguros.Documento _documento; + + private Visibility _ocultarInfos; + + private bool _carregando; + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + base.OnPropertyChanged("Carregando"); + } + } + + public ObservableCollection Contatos + { + get + { + return this._contatos; + } + set + { + this._contatos = value; + base.OnPropertyChanged("Contatos"); + } + } + + public Gestor.Model.Domain.Seguros.Documento Documento + { + get + { + return this._documento; + } + set + { + this._documento = value; + base.OnPropertyChanged("Documento"); + } + } + + public ObservableCollection Itens + { + get + { + return this._itens; + } + set + { + this._itens = value; + base.OnPropertyChanged("Itens"); + } + } + + public Visibility OcultarInfos + { + get + { + return this._ocultarInfos; + } + set + { + this._ocultarInfos = value; + base.OnPropertyChanged("OcultarInfos"); + } + } + + public ObservableCollection Parcelas + { + get + { + return this._parcelas; + } + set + { + this._parcelas = value; + base.OnPropertyChanged("Parcelas"); + } + } + + public InfoViewModel(Gestor.Model.Domain.Seguros.Documento documento, bool ocultarInfos) + { + this.Documento = documento; + this.OcultarInfos = (ocultarInfos ? Visibility.Collapsed : Visibility.Visible); + this.Seleciona(); + } + + public string GerarObs(Gestor.Model.Domain.Seguros.Documento doc) + { + if (doc.get_Tipo() == 0) + { + return string.Format("CLIENTE: {0}{1}CÓDIGO: {2}{3}PROPOSTA: {4}{5}APÓLICE: {6}", new object[] { doc.get_Controle().get_Cliente().get_Nome(), Environment.NewLine, doc.get_Id(), Environment.NewLine, doc.get_Proposta(), Environment.NewLine, doc.get_Apolice() }); + } + return string.Format("CLIENTE: {0}{1}CÓDIGO: {2}{3}PROPOSTA: {4}{5}APÓLICE: {6}{7}PROPOSTA DE ENDOSSO: {8}{9}ENDOSSO: {10}", new object[] { doc.get_Controle().get_Cliente().get_Nome(), Environment.NewLine, doc.get_Id(), Environment.NewLine, doc.get_Proposta(), Environment.NewLine, doc.get_Apolice(), Environment.NewLine, doc.get_PropostaEndosso(), Environment.NewLine, doc.get_Endosso() }); + } + + public async void Seleciona() + { + bool controle; + ObservableCollection observableCollection; + this.Carregando = true; + if (this.Documento != null) + { + this.Documento = await (new ApoliceServico()).BuscarApoliceAsync(this.Documento.get_Id(), false, false); + } + if (this.OcultarInfos == Visibility.Visible && this.Documento != null) + { + ObservableCollection observableCollection1 = await (new ParcelaServico()).BuscarParcelasAsync(this.Documento.get_Id()); + InfoViewModel infoViewModel = this; + if (this.Documento.get_TipoRecebimento().GetValueOrDefault() == 2) + { + ObservableCollection observableCollection2 = observableCollection1; + observableCollection = new ObservableCollection( + from x in observableCollection2 + orderby x.get_VigenciaIncial() descending + select x); + } + else + { + observableCollection = observableCollection1; + } + infoViewModel.Parcelas = observableCollection; + } + Gestor.Model.Domain.Seguros.Documento documento = this.Documento; + if (documento != null) + { + controle = documento.get_Controle(); + } + else + { + controle = false; + } + if (controle) + { + this.Itens = await (new ItemServico()).BuscarItens(this.Documento.get_Controle().get_Id(), 0); + List contatos = new List(); + ClienteServico clienteServico = new ClienteServico(); + if (this.Documento.get_Controle().get_Cliente() != null) + { + ObservableCollection observableCollection3 = await clienteServico.BuscarTelefonesAsync(this.Documento.get_Controle().get_Cliente().get_Id()); + ObservableCollection observableCollection4 = await clienteServico.BuscarEmailsAsync(this.Documento.get_Controle().get_Cliente().get_Id()); + if (observableCollection3 != null) + { + List contatos1 = contatos; + ObservableCollection observableCollection5 = observableCollection3; + contatos1.AddRange(observableCollection5.Select((ClienteTelefone x) => { + Contato contato = new Contato(); + contato.set_Tipo(0); + contato.set_TipoTelefone(new TipoTelefone?(x.get_Tipo().GetValueOrDefault(1))); + contato.set_Numero(string.Concat(x.get_Prefixo(), " ", x.get_Numero())); + return contato; + }).Take(2).ToList()); + } + if (observableCollection4 != null) + { + List contatos2 = contatos; + ObservableCollection observableCollection6 = observableCollection4; + contatos2.AddRange(observableCollection6.Select((ClienteEmail x) => { + Contato contato = new Contato(); + contato.set_Tipo(1); + contato.set_TipoTelefone(null); + contato.set_Numero(x.get_Email()); + return contato; + }).Take(1).ToList()); + } + observableCollection3 = null; + } + this.Contatos = new ObservableCollection(contatos); + contatos = null; + clienteServico = null; + } + this.Carregando = false; + } + } +} \ No newline at end of file -- cgit v1.2.3