diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs | 183 |
1 files changed, 0 insertions, 183 deletions
diff --git a/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs b/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs deleted file mode 100644 index dd3313a..0000000 --- a/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs +++ /dev/null @@ -1,183 +0,0 @@ -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.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class PerfilViewModel : BaseViewModel
- {
- private readonly PerfilServico _servico;
-
- private readonly Controle _controle;
-
- public long CancelPerfil;
-
- private Perfil _selectedPerfil = new Perfil();
-
- private ObservableCollection<Perfil> _perfis;
-
- public ObservableCollection<Perfil> Perfis
- {
- get
- {
- return this._perfis;
- }
- set
- {
- this._perfis = value;
- base.OnPropertyChanged("Perfis");
- }
- }
-
- public Perfil SelectedPerfil
- {
- get
- {
- return this._selectedPerfil;
- }
- set
- {
- long? nullable;
- this._selectedPerfil = value;
- if (value != null && value.get_Id() > (long)0)
- {
- this.CancelPerfil = value.get_Id();
- }
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedPerfil");
- }
- }
-
- public PerfilViewModel(Controle controle)
- {
- this._servico = new PerfilServico();
- this._controle = controle;
- this.Seleciona(controle.get_Id());
- }
-
- public void CancelarAlteracao()
- {
- base.Loading(true);
- if (this.CancelPerfil > (long)0)
- {
- this.SelectedPerfil = this.Perfis.FirstOrDefault<Perfil>((Perfil x) => x.get_Id() == this.CancelPerfil);
- }
- base.Alterar(false);
- base.Loading(false);
- }
-
- public async Task Excluir()
- {
- if (this.SelectedPerfil != null && this.SelectedPerfil.get_Id() != 0)
- {
- if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool selectedPerfil = (object)this.SelectedPerfil == (object)this.Perfis.Last<Perfil>();
- if (await this._servico.Delete(this.SelectedPerfil))
- {
- if (selectedPerfil)
- {
- int num = this.Perfis.IndexOf(this.SelectedPerfil);
- if (num <= 0)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), (long)0);
- }
- else
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.Perfis[num - 1].get_Id());
- }
- }
- else if (this.Perfis.Count > 0)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.Perfis[this.Perfis.IndexOf(this.SelectedPerfil) + 1].get_Id());
- }
- base.Loading(false);
- base.ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO", true);
- }
- else
- {
- base.Loading(false);
- }
- }
- }
- }
-
- public void Incluir()
- {
- Perfil perfil = new Perfil();
- perfil.set_Controle(this._controle);
- perfil.set_Cliente(this._controle.get_Cliente());
- perfil.set_UsoProfissional(new bool?(false));
- perfil.set_AntiFurto(new Antifurto?(0));
- perfil.set_Isencao(new bool?(false));
- perfil.set_SeguroVida(new bool?(false));
- perfil.set_EstenderCobertura(new bool?(false));
- this.SelectedPerfil = perfil;
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedPerfil.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- this.SelectedPerfil = await this._servico.Save(this.SelectedPerfil);
- if (this._servico.Sucesso)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.SelectedPerfil.get_Id());
- base.ToggleSnackBar("PERFIL SALVO COM SUCESSO", true);
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- return keyValuePairs;
- }
-
- private async void Seleciona(long id)
- {
- base.Loading(true);
- await base.PermissaoTela(32);
- await this.SelecionaPerfis(id, (long)0);
- base.Loading(false);
- }
-
- private async Task SelecionaPerfis(long id, long perfilId = 0L)
- {
- Perfil perfil;
- base.Loading(true);
- this.Perfis = new ObservableCollection<Perfil>(await this._servico.BuscarPerfis(id));
- PerfilViewModel perfilViewModel = this;
- perfil = (perfilId == 0 ? this.Perfis.FirstOrDefault<Perfil>() : this.Perfis.First<Perfil>((Perfil x) => x.get_Id() == perfilId));
- perfilViewModel.SelectedPerfil = perfil;
- base.Loading(false);
- }
- }
-}
\ No newline at end of file |