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 --- .../Gestor.Application/ViewModels/MainViewModel.cs | 1273 ++++++++++++++++++++ 1 file changed, 1273 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/MainViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/MainViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/MainViewModel.cs b/Codemerx/Gestor.Application/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..26324af --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/MainViewModel.cs @@ -0,0 +1,1273 @@ +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Financeiro; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Card; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +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; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + +namespace Gestor.Application.ViewModels +{ + public class MainViewModel : BaseSegurosViewModel + { + public Gestor.Application.Views.Financeiro.FinanceiroView FinanceiroView; + + public Gestor.Application.ViewModels.Seguros.ConsultaViewModel ConsultaViewModel; + + public Gestor.Application.ViewModels.Seguros.ClienteViewModel ClienteViewModel; + + private readonly ClienteServico _servico; + + public Gestor.Application.ViewModels.DashboardViewModel DashboardViewModel; + + private List _boletos; + + private BitmapImage _qrCode; + + private string _code; + + private Geometry _maximizeRestore = Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]); + + private object _content; + + private double _headMaxWidth; + + private string _head; + + private string _tela; + + private TipoTela? _telaAberta; + + private string _versao; + + private long _selectedRamo = (long)5; + + public bool PesquisaAvançada; + + private Cliente _selectedCliente; + + private bool _isEnableDocumento; + + private bool _isEnableItens; + + private Gestor.Model.Common.TipoDocumento _tipoDocumento; + + private string _documentoPrincipal = ""; + + private ObservableCollection _ajuda = new ObservableCollection(); + + private bool _matrizFilial = LicenseHelper.Produtos.Any(new Func((Licenca x) => { + if (x.get_Produto() != 2) + { + return false; + } + return x.get_Status() == 1; + })); + + private readonly bool _temEpic = LicenseHelper.Produtos.Any(new Func((Licenca produto) => { + if (produto.get_Produto() != 83) + { + return false; + } + return produto.get_Status() == 1; + })); + + private bool _carregandoAjuda; + + private string _empresa = ""; + + private ObservableCollection _contatos = new ObservableCollection(); + + private int _liquido; + + private int _mediaComissao; + + private int _resultado; + + private Visibility _visibleChaveInstalacao = Visibility.Collapsed; + + private Visibility _visibleSeguros = Visibility.Collapsed; + + private Visibility _visibleBi = Visibility.Collapsed; + + private FiltroStatusDocumento _selectedStatus; + + private TipoFiltroCliente _selectedFiltroCliente = 1; + + private bool _buscaNome = true; + + private bool _enableSeguros; + + private bool _enableBuscar; + + private Visibility _visibilityVoltar = Visibility.Collapsed; + + private int _notasBadge; + + private int _tarefasBadge; + + private int _badges; + + private int _ultimoUpdate; + + private Visibility _mensagemTarefasVisibility = Visibility.Collapsed; + + private string _mensagemTarefas = ""; + + private string _pesquisa = ""; + + private int _medalhaCor; + + private Visibility _medalhaVisibility = Visibility.Collapsed; + + private string _placeHolderAutoComplete = "PESQUISAR CLIENTE POR NOME OU NOME SOCIAL"; + + public ObservableCollection Ajuda + { + get + { + return this._ajuda; + } + set + { + this._ajuda = value; + base.OnPropertyChanged("Ajuda"); + } + } + + public int Badges + { + get + { + return this._badges; + } + set + { + this._badges = value; + base.OnPropertyChanged("Badges"); + } + } + + public List Boletos + { + get + { + return this._boletos; + } + set + { + this._boletos = value; + base.OnPropertyChanged("Boletos"); + } + } + + public bool BuscaNome + { + get + { + return this._buscaNome; + } + set + { + this._buscaNome = value; + base.OnPropertyChanged("BuscaNome"); + } + } + + public bool CarregandoAjuda + { + get + { + return this._carregandoAjuda; + } + set + { + this._carregandoAjuda = value; + base.OnPropertyChanged("CarregandoAjuda"); + } + } + + public static Cliente ClienteSelecionado + { + get; + set; + } + + public List ClientesEncontrados + { + get; + set; + } + + public List ClientesFiltrados + { + get; + set; + } + + public string Code + { + get + { + return this._code; + } + set + { + this._code = value; + base.OnPropertyChanged("Code"); + } + } + + public ObservableCollection Contatos + { + get + { + return this._contatos; + } + set + { + this._contatos = value; + base.OnPropertyChanged("Contatos"); + } + } + + public object Content + { + get + { + return this._content; + } + set + { + this._content = value; + base.OnPropertyChanged("Content"); + } + } + + public string DocumentoPrincipal + { + get + { + return this._documentoPrincipal; + } + set + { + this._documentoPrincipal = value; + base.OnPropertyChanged("DocumentoPrincipal"); + } + } + + public string Empresa + { + get + { + return this._empresa; + } + set + { + this._empresa = value; + base.OnPropertyChanged("Empresa"); + } + } + + public bool EnableBuscar + { + get + { + return this._enableBuscar; + } + set + { + this._enableBuscar = value; + base.OnPropertyChanged("EnableBuscar"); + } + } + + public bool EnableSeguros + { + get + { + return this._enableSeguros; + } + set + { + this._enableSeguros = value; + base.OnPropertyChanged("EnableSeguros"); + } + } + + public string Head + { + get + { + return this._head; + } + set + { + this._head = value; + base.OnPropertyChanged("Head"); + } + } + + public double HeadMaxWidth + { + get + { + return this._headMaxWidth; + } + set + { + this._headMaxWidth = value; + base.OnPropertyChanged("HeadMaxWidth"); + } + } + + public bool Invoke { get; set; } = true; + + public bool Isdropped + { + get; + set; + } + + public bool IsEnableDocumento + { + get + { + return this._isEnableDocumento; + } + set + { + this._isEnableDocumento = value; + base.OnPropertyChanged("IsEnableDocumento"); + } + } + + public bool IsEnableItens + { + get + { + return this._isEnableItens; + } + set + { + this._isEnableItens = value; + base.OnPropertyChanged("IsEnableItens"); + } + } + + public bool IsPopulating + { + get; + set; + } + + public bool MatrizFilial + { + get + { + return this._matrizFilial; + } + set + { + this._matrizFilial = value; + base.OnPropertyChanged("MatrizFilial"); + } + } + + public Geometry MaximizeRestore + { + get + { + return this._maximizeRestore; + } + set + { + this._maximizeRestore = value; + base.OnPropertyChanged("MaximizeRestore"); + } + } + + public int MedalhaCor + { + get + { + return this._medalhaCor; + } + set + { + this._medalhaCor = value; + base.OnPropertyChanged("MedalhaCor"); + } + } + + public Visibility MedalhaVisibility + { + get + { + return this._medalhaVisibility; + } + set + { + this._medalhaVisibility = value; + base.OnPropertyChanged("MedalhaVisibility"); + } + } + + public string MensagemTarefas + { + get + { + return this._mensagemTarefas; + } + set + { + this._mensagemTarefas = value; + base.OnPropertyChanged("MensagemTarefas"); + } + } + + public Visibility MensagemTarefasVisibility + { + get + { + return this._mensagemTarefasVisibility; + } + set + { + this._mensagemTarefasVisibility = value; + base.OnPropertyChanged("MensagemTarefasVisibility"); + } + } + + public int NotasBadge + { + get + { + return this._notasBadge; + } + set + { + this._notasBadge = value; + this.Badges = value + this.TarefasBadge; + base.OnPropertyChanged("NotasBadge"); + } + } + + public string Pesquisa + { + get + { + return this._pesquisa; + } + set + { + this._pesquisa = value; + base.OnPropertyChanged("Pesquisa"); + } + } + + public string PlaceHolderAutoComplete + { + get + { + return this._placeHolderAutoComplete; + } + set + { + this._placeHolderAutoComplete = value; + base.OnPropertyChanged("PlaceHolderAutoComplete"); + } + } + + public BitmapImage QrCode + { + get + { + return this._qrCode; + } + set + { + this._qrCode = value; + base.OnPropertyChanged("QrCode"); + } + } + + public Cliente SelectedCliente + { + get + { + return this._selectedCliente; + } + set + { + long? nullable; + if (this.Invoke) + { + if (value != null) + { + long id = value.get_Id(); + Cliente selectedCliente = this.SelectedCliente; + if (selectedCliente != null) + { + nullable = new long?(selectedCliente.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + if (id == nullable1.GetValueOrDefault() & nullable1.HasValue) + { + this._selectedCliente = value; + base.OnPropertyChanged("SelectedCliente"); + return; + } + } + MainViewModel.ClienteSelecionado = value; + } + this._selectedCliente = value; + base.OnPropertyChanged("SelectedCliente"); + } + } + + public TipoFiltroCliente SelectedFiltroCliente + { + get + { + return this._selectedFiltroCliente; + } + set + { + this._selectedFiltroCliente = value; + this.BuscaNome = value == 1; + this.PlaceHolderAutoComplete = (this._selectedFiltroCliente == null ? "PESQUISAR CLIENTE POR NOME OU SOBRENOME" : "PESQUISAR CLIENTE POR NOME OU DOCUMENTO"); + base.OnPropertyChanged("SelectedFiltroCliente"); + } + } + + public long SelectedRamo + { + get + { + return this._selectedRamo; + } + set + { + this._selectedRamo = value; + base.OnPropertyChanged("SelectedRamo"); + } + } + + public FiltroStatusDocumento SelectedStatus + { + get + { + return this._selectedStatus; + } + set + { + this._selectedStatus = value; + this.WorkOnSelectedStatus(value); + base.OnPropertyChanged("SelectedStatus"); + } + } + + public static FiltroStatusDocumento StatusSelecionado + { + get; + set; + } + + public int TarefasBadge + { + get + { + return this._tarefasBadge; + } + set + { + this._tarefasBadge = value; + this.Badges = value + this.NotasBadge; + base.OnPropertyChanged("TarefasBadge"); + } + } + + public string Tela + { + get + { + return this._tela; + } + set + { + this._tela = value; + base.OnPropertyChanged("Tela"); + } + } + + public TipoTela? TelaAberta + { + get + { + return this._telaAberta; + } + set + { + this._telaAberta = value; + base.OnPropertyChanged("TelaAberta"); + } + } + + public Visibility TemEpic + { + get + { + if (!this._temEpic) + { + return Visibility.Collapsed; + } + return Visibility.Visible; + } + } + + public Gestor.Model.Common.TipoDocumento TipoDocumento + { + get + { + return this._tipoDocumento; + } + set + { + this._tipoDocumento = value; + base.OnPropertyChanged("TipoDocumento"); + } + } + + public List VendedorUsuario + { + get; + set; + } + + public string Versao + { + get + { + return this._versao; + } + set + { + this._versao = value; + base.OnPropertyChanged("Versao"); + } + } + + public static string ViewAberta + { + get; + set; + } + + public Visibility VisibilityVoltar + { + get + { + return this._visibilityVoltar; + } + set + { + this._visibilityVoltar = value; + base.OnPropertyChanged("VisibilityVoltar"); + } + } + + public Visibility VisibleBi + { + get + { + return this._visibleBi; + } + set + { + this._visibleBi = value; + base.OnPropertyChanged("VisibleBi"); + } + } + + public Visibility VisibleChaveInstalacao + { + get + { + return this._visibleChaveInstalacao; + } + set + { + this._visibleChaveInstalacao = value; + base.OnPropertyChanged("VisibleChaveInstalacao"); + } + } + + public Visibility VisibleSeguros + { + get + { + return this._visibleSeguros; + } + set + { + this._visibleSeguros = value; + base.OnPropertyChanged("VisibleSeguros"); + } + } + + public MainViewModel() + { + TipoFiltroCliente? nullable; + TipoFiltroCliente? filtroInicial; + Gestor.Application.Actions.Actions.AtualizaBadges = new Action(this.AtualizarBadges); + Gestor.Application.Actions.Actions.LimparCliente = new Action(this.LimparCliente); + this._servico = new ClienteServico(); + Gestor.Application.Actions.Actions.UpdateDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateDocumento, new Action(this.UpdateRamoIcon)); + Gestor.Application.Actions.Actions.SelectCliente = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.SelectCliente, new Action(this.SelectCliente)); + Gestor.Application.Actions.Actions.AtualizaContatos = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaContatos, new Action(this.AtualizarContatos)); + Gestor.Application.Actions.Actions.EnableItens = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.EnableItens, new Action(this.EnableItens)); + Gestor.Application.Actions.Actions.EnableDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.EnableDocumento, new Action(this.EnableDocumento)); + this.Versao = string.Concat(Recursos.Empresa.get_Nome(), " | ", LoginViewModel.VersaoAtual); + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + filtroInicial = usuario.get_FiltroInicial(); + } + else + { + nullable = null; + filtroInicial = nullable; + } + nullable = filtroInicial; + this.SelectedFiltroCliente = nullable.GetValueOrDefault(); + (new DispatcherTimer(TimeSpan.FromHours(1), DispatcherPriority.Background, (object sender, EventArgs args) => this.AtualizarBadges(), System.Windows.Application.Current.Dispatcher)).Start(); + } + + private async void AtualizarBadges() + { + object obj; + object obj1; + try + { + int[] numArray = await (new TarefaServico()).AtualizarNotasTarefas(); + this.NotasBadge = numArray[0]; + this.TarefasBadge = numArray[1]; + if (numArray[1] > this._ultimoUpdate) + { + MainViewModel mainViewModel = this; + object obj2 = numArray[1]; + obj = (numArray[1] > 1 ? "S" : ""); + obj1 = (numArray[1] > 1 ? "S" : ""); + mainViewModel.MensagemTarefas = string.Format("{0} NOVA{1} TAREFA{2}", obj2, obj, obj1); + this.MensagemTarefasVisibility = Visibility.Visible; + } + this._ultimoUpdate = numArray[1]; + } + catch + { + } + } + + private async void AtualizarContatos() + { + ObservableCollection observableCollection; + List contatos = new List(); + if (this.SelectedCliente != null) + { + observableCollection = await this._servico.BuscarTelefonesAsync(this.SelectedCliente.get_Id()); + ObservableCollection observableCollection1 = await this._servico.BuscarEmailsAsync(this.SelectedCliente.get_Id()); + if (observableCollection != null) + { + List contatos1 = contatos; + ObservableCollection observableCollection2 = observableCollection; + contatos1.AddRange(observableCollection2.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 (observableCollection1 != null) + { + List contatos2 = contatos; + ObservableCollection observableCollection3 = observableCollection1; + contatos2.AddRange(observableCollection3.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()); + } + this.Contatos = new ObservableCollection(contatos); + } + contatos = null; + observableCollection = null; + } + + private async void AtualizarMedalha(List apolices) + { + decimal zero; + Qualificacao qualificacao = await this._servico.BuscarQualificacaoAsync(); + if (qualificacao.get_Id() == 0) + { + Qualificacao qualificacao1 = new Qualificacao(); + qualificacao1.set_Liquido1(decimal.Zero); + qualificacao1.set_Liquido2(new decimal(1000)); + qualificacao1.set_Liquido3(new decimal(5000)); + qualificacao1.set_Comissao1(new decimal(10)); + qualificacao1.set_Comissao2(new decimal(15)); + qualificacao1.set_Comissao3(new decimal(20)); + qualificacao1.set_Resultado1(new decimal(100)); + qualificacao1.set_Resultado2(new decimal(200)); + qualificacao1.set_Resultado3(new decimal(300)); + qualificacao1.set_Id((long)1); + qualificacao = qualificacao1; + } + this._liquido = 0; + this._mediaComissao = 0; + this._resultado = 0; + List documentos = apolices; + decimal num = documentos.Sum((Documento p) => p.get_PremioLiquido()); + if (num >= qualificacao.get_Liquido3()) + { + this._liquido = 3; + } + else if (num >= qualificacao.get_Liquido2()) + { + this._liquido = 2; + } + else if (num >= qualificacao.get_Liquido1()) + { + this._liquido = 1; + } + List documentos1 = apolices; + if (documentos1.Any((Documento c) => c.get_Comissao() > decimal.Zero)) + { + List documentos2 = apolices; + decimal num1 = documentos2.Sum((Documento c) => c.get_Comissao()); + zero = decimal.Round(num1 / apolices.Count((Documento c) => c.get_Comissao() > decimal.Zero), 2); + } + else + { + zero = decimal.Zero; + } + decimal num2 = zero; + if (num2 >= qualificacao.get_Comissao3()) + { + this._mediaComissao = 3; + } + else if (num2 >= qualificacao.get_Comissao2()) + { + this._mediaComissao = 2; + } + else if (num2 >= qualificacao.get_Comissao1()) + { + this._mediaComissao = 1; + } + List documentos3 = apolices; + decimal num3 = documentos3.Sum((Documento p) => ((p.get_PremioLiquido() + (p.get_AdicionalComiss() ? p.get_PremioAdicional() : decimal.Zero)) * p.get_Comissao()) * new decimal(1, 0, 0, false, 2)); + if (num3 >= qualificacao.get_Resultado3()) + { + this._resultado = 3; + } + else if (num3 >= qualificacao.get_Resultado2()) + { + this._resultado = 2; + } + else if (num3 >= qualificacao.get_Resultado1()) + { + this._resultado = 1; + } + this.MedalhaCor = (int)Math.Round((double)(((float)this._liquido + (float)this._mediaComissao + (float)this._resultado) / 3f)); + this.MedalhaVisibility = Visibility.Visible; + } + + public async Task CarregarAjuda() + { + if (this.TelaAberta.HasValue) + { + if (!this.Ajuda.Any((AjudaTela x) => { + TipoTela tela = x.get_Tela(); + TipoTela? telaAberta = this.TelaAberta; + return tela == telaAberta.GetValueOrDefault() & telaAberta.HasValue; + })) + { + this.CarregandoAjuda = true; + TipoTela? nullable = this.TelaAberta; + this.Ajuda = new ObservableCollection(await Connection.Get>(string.Format("Help/{0}", (int)nullable.Value), true, false)); + this.CarregandoAjuda = false; + } + } + } + + private void EnableDocumento(bool enabled) + { + this.IsEnableDocumento = enabled; + } + + private void EnableItens(bool enabled) + { + this.IsEnableItens = enabled; + } + + public List FiltrarClientes(string value) + { + return base.FilterCliente(this.ClientesEncontrados, value); + } + + private void LimparCliente() + { + this.SelectedCliente = null; + this.Contatos = null; + this.DocumentoPrincipal = ""; + this.Pesquisa = ""; + } + + public async void LimparDocumentos() + { + Task task; + this.Contatos = null; + this.DocumentoPrincipal = ""; + string viewAberta = MainViewModel.ViewAberta; + if (viewAberta != "ConsultaOriginalView") + { + if (viewAberta == "ClienteView") + { + Gestor.Application.ViewModels.Seguros.ClienteViewModel clienteViewModel = this.ClienteViewModel; + if (clienteViewModel != null) + { + clienteViewModel.SelecionaCliente(null); + } + else + { + } + } + } + else if (this.ConsultaViewModel != null) + { + Gestor.Application.ViewModels.Seguros.ConsultaViewModel consultaViewModel = this.ConsultaViewModel; + if (consultaViewModel != null) + { + task = consultaViewModel.SelecionaCliente(null, true); + } + else + { + task = null; + } + await task; + } + } + + public async void Medalha() + { + await base.ShowMedalha(this._liquido, this._mediaComissao, this._resultado, this.MedalhaCor); + } + + public async Task SelecionarCliente(Cliente value) + { + this.IsEnableDocumento = false; + this.IsEnableItens = false; + this.LimparDocumentos(); + if (value != null) + { + if (this.Invoke) + { + MainViewModel.ClienteSelecionado = value; + } + await this.WorkOnSelectedCliente(value); + this.IsEnableDocumento = true; + } + } + + private void SelectCliente(Cliente cliente) + { + string str; + string str1; + this.SelectedCliente = cliente; + string pesquisa = this.Pesquisa; + if (cliente != null) + { + string nomeSocial = cliente.get_NomeSocial(); + if (nomeSocial != null) + { + str = nomeSocial.Trim(); + } + else + { + str = null; + } + } + else + { + str = null; + } + if (pesquisa != str) + { + if (cliente != null) + { + string nomeSocial1 = cliente.get_NomeSocial(); + if (nomeSocial1 != null) + { + str1 = nomeSocial1.Trim(); + } + else + { + str1 = null; + } + } + else + { + str1 = null; + } + this.Pesquisa = str1; + } + } + + private void UpdateRamoIcon(Documento documento) + { + if (documento == null || documento.get_Id() == 0) + { + return; + } + this.SelectedRamo = documento.get_Controle().get_Ramo().get_Id(); + } + + public async void VerificarLogo() + { + if (string.IsNullOrEmpty(Recursos.Empresa.get_LogoId()) && Recursos.Empresa.get_Logo() != null) + { + Logo logo = new Logo(); + logo.set_CustomId(ApplicationHelper.NumeroSerial); + logo.set_Data(Recursos.Empresa.get_Logo()); + Gestor.Model.Domain.Common.Empresa empresa = Recursos.Empresa; + empresa.set_LogoId(await Funcoes.Criarlogo(logo)); + empresa = null; + (new EmpresaServico()).AtualizarLogoId(Recursos.Empresa.get_Id(), Recursos.Empresa.get_LogoId()); + } + } + + private async Task WorkOnSelectedCliente(Cliente value) + { + object nome; + string nomeSocial; + Task task; + long? nullable; + base.IsEnabled = false; + List contatos = new List(); + ObservableCollection observableCollection = await this._servico.BuscarTelefonesAsync(value.get_Id()); + ObservableCollection observableCollection1 = await this._servico.BuscarEmailsAsync(value.get_Id()); + if (observableCollection != null) + { + List contatos1 = contatos; + ObservableCollection observableCollection2 = observableCollection; + contatos1.AddRange(observableCollection2.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 (observableCollection1 != null) + { + List contatos2 = contatos; + ObservableCollection observableCollection3 = observableCollection1; + contatos2.AddRange(observableCollection3.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()); + } + this.Contatos = new ObservableCollection(contatos); + this.TipoDocumento = value.get_DocumentoPrincipal().GetValueOrDefault(); + MainViewModel mainViewModel = this; + Gestor.Model.Domain.Common.Empresa empresa = Recursos.Empresas.FirstOrDefault((Gestor.Model.Domain.Common.Empresa x) => x.get_Id() == value.get_IdEmpresa()); + if (empresa != null) + { + nome = empresa.get_Nome(); + } + else + { + nome = null; + } + if (nome == null) + { + nome = Recursos.Empresa.get_Nome(); + } + mainViewModel.Empresa = (string)nome; + switch (this.TipoDocumento) + { + case 0: + { + MainViewModel mainViewModel1 = this; + string documento = value.get_Documento(); + if (documento == null) + { + documento = ""; + } + mainViewModel1.DocumentoPrincipal = documento; + break; + } + case 1: + { + MainViewModel mainViewModel2 = this; + string rne = value.get_Rne(); + if (rne == null) + { + rne = ""; + } + mainViewModel2.DocumentoPrincipal = rne; + break; + } + case 2: + { + MainViewModel mainViewModel3 = this; + string cei = value.get_Cei(); + if (cei == null) + { + cei = ""; + } + mainViewModel3.DocumentoPrincipal = cei; + break; + } + case 3: + { + MainViewModel mainViewModel4 = this; + string caepf = value.get_Caepf(); + if (caepf == null) + { + caepf = ""; + } + mainViewModel4.DocumentoPrincipal = caepf; + break; + } + } + if (MainViewModel.ClienteSelecionado != null) + { + MainViewModel.ClienteSelecionado.set_Telefones(observableCollection); + MainViewModel.ClienteSelecionado.set_Emails(observableCollection1); + } + string viewAberta = MainViewModel.ViewAberta; + if (viewAberta != "ConsultaOriginalView") + { + if (viewAberta == "ClienteView") + { + Gestor.Application.ViewModels.Seguros.ClienteViewModel clienteViewModel = this.ClienteViewModel; + if (clienteViewModel != null) + { + clienteViewModel.SelecionaCliente(this.SelectedCliente); + } + else + { + } + MainViewModel mainViewModel5 = this; + string str = string.Concat("ACESSOU CLIENTE \"", this.SelectedCliente.get_Nome(), "\""); + long id = this.SelectedCliente.get_Id(); + TipoTela? nullable1 = new TipoTela?(1); + Cliente selectedCliente = this.SelectedCliente; + if (selectedCliente != null) + { + nullable = new long?(selectedCliente.get_Id()); + } + else + { + nullable = null; + } + mainViewModel5.RegistrarAcao(str, id, nullable1, string.Format("ID CLIENTE: {0}", nullable)); + } + } + else if (this.ConsultaViewModel != null) + { + Gestor.Application.ViewModels.Seguros.ConsultaViewModel consultaViewModel = this.ConsultaViewModel; + if (consultaViewModel != null) + { + task = consultaViewModel.SelecionaCliente(value, true); + } + else + { + task = null; + } + await task; + this.AtualizarMedalha(this.ConsultaViewModel.Apolices.ToList()); + } + base.IsEnabled = true; + MainViewModel mainViewModel6 = this; + Cliente cliente = this.SelectedCliente; + if (cliente != null) + { + nomeSocial = cliente.get_NomeSocial(); + } + else + { + nomeSocial = null; + } + mainViewModel6.Pesquisa = nomeSocial; + contatos = null; + observableCollection = null; + } + + private void WorkOnSelectedStatus(FiltroStatusDocumento value) + { + MainViewModel.StatusSelecionado = value; + if (this.SelectedCliente == null) + { + return; + } + if (!this.Invoke) + { + return; + } + string viewAberta = MainViewModel.ViewAberta; + if (viewAberta == "ConsultaOriginalView") + { + Gestor.Application.ViewModels.Seguros.ConsultaViewModel consultaViewModel = this.ConsultaViewModel; + if (consultaViewModel == null) + { + return; + } + consultaViewModel.SelecionarCliente(this.SelectedCliente); + return; + } + if (viewAberta != "ClienteView") + { + return; + } + Gestor.Application.ViewModels.Seguros.ClienteViewModel clienteViewModel = this.ClienteViewModel; + if (clienteViewModel == null) + { + return; + } + clienteViewModel.SelecionaCliente(this.SelectedCliente); + } + } +} \ No newline at end of file -- cgit v1.2.3