summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs')
-rw-r--r--Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs
new file mode 100644
index 0000000..35881fd
--- /dev/null
+++ b/Codemerx/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs
@@ -0,0 +1,92 @@
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.ViewModels.Seguros
+{
+ public class TrocarClienteViewModel : BaseSegurosViewModel
+ {
+ private readonly ApoliceServico _apoliceServico;
+
+ private readonly ClienteServico _clienteServico;
+
+ private Documento _selectedDocumento;
+
+ private Cliente _selectedCliente;
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return this._selectedCliente;
+ }
+ set
+ {
+ base.OnPropertyChanged("SelectedCliente");
+ this._selectedCliente = value;
+ }
+ }
+
+ public Documento SelectedDocumento
+ {
+ get
+ {
+ return this._selectedDocumento;
+ }
+ set
+ {
+ base.OnPropertyChanged("SelectedDocumento");
+ this._selectedDocumento = value;
+ }
+ }
+
+ public TrocarClienteViewModel()
+ {
+ this._apoliceServico = new ApoliceServico();
+ this._clienteServico = new ClienteServico();
+ }
+
+ public async Task<bool> Salvar()
+ {
+ bool flag;
+ Cliente cliente;
+ Documento selectedDocumento;
+ if (this.SelectedCliente == null)
+ {
+ flag = false;
+ }
+ else if (this.SelectedCliente.get_Id() != this.SelectedDocumento.get_Controle().get_Cliente().get_Id())
+ {
+ cliente = await this._clienteServico.BuscarCliente(this.SelectedDocumento.get_Controle().get_Cliente().get_Id());
+ selectedDocumento = this.SelectedDocumento;
+ this._apoliceServico.Sucesso = true;
+ await this._apoliceServico.Save(selectedDocumento.get_Controle(), this.SelectedCliente);
+ if (this._apoliceServico.Sucesso)
+ {
+ base.RegistrarAcao(string.Format("TROCOU O CLIENTE DO DOCUMENTO DE ID {0}", this.SelectedDocumento.get_Id()), this.SelectedDocumento.get_Id(), new TipoTela?(41), string.Format("CLIENTE ANTIGO: {0}\nNOVO CLIENTE: {1} ({2})", cliente.get_Nome(), this.SelectedCliente.get_Nome(), this.SelectedCliente.get_Id()));
+ this.SelectedCliente = selectedDocumento.get_Controle().get_Cliente();
+ this.SelectedDocumento = selectedDocumento;
+ flag = true;
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ else
+ {
+ flag = false;
+ }
+ cliente = null;
+ selectedDocumento = null;
+ return flag;
+ }
+ }
+} \ No newline at end of file