diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs new file mode 100644 index 0000000..2515b35 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +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 Perfil SelectedPerfil + { + get + { + return _selectedPerfil; + } + set + { + _selectedPerfil = value; + if (value != null && ((DomainBase)value).Id > 0) + { + CancelPerfil = ((DomainBase)value).Id; + } + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedPerfil"); + } + } + + public ObservableCollection<Perfil> Perfis + { + get + { + return _perfis; + } + set + { + _perfis = value; + OnPropertyChanged("Perfis"); + } + } + + public PerfilViewModel(Controle controle) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new PerfilServico(); + _controle = controle; + Seleciona(((DomainBase)controle).Id); + } + + private async void Seleciona(long id) + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)32); + await SelecionaPerfis(id, 0L); + Loading(isLoading: false); + } + + private async Task SelecionaPerfis(long id, long perfilId = 0L) + { + Loading(isLoading: true); + Perfis = new ObservableCollection<Perfil>(await _servico.BuscarPerfis(id)); + SelectedPerfil = (Perfil)((perfilId == 0L) ? ((object)Perfis.FirstOrDefault()) : ((object)Perfis.First((Perfil x) => ((DomainBase)x).Id == perfilId))); + Loading(isLoading: false); + } + + public void Incluir() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + Perfil selectedPerfil = new Perfil + { + Controle = _controle, + Cliente = _controle.Cliente, + UsoProfissional = false, + AntiFurto = (Antifurto)0, + Isencao = false, + SeguroVida = false, + EstenderCobertura = false + }; + SelectedPerfil = selectedPerfil; + Alterar(alterar: true); + } + + public async Task<List<KeyValuePair<string, string>>> Salvar() + { + List<KeyValuePair<string, string>> list = SelectedPerfil.Validate(); + if (list.Count > 0) + { + return list; + } + SelectedPerfil = await _servico.Save(SelectedPerfil); + if (!_servico.Sucesso) + { + return null; + } + await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)SelectedPerfil).Id); + ToggleSnackBar("PERFIL SALVO COM SUCESSO"); + Alterar(alterar: false); + return null; + } + + public void CancelarAlteracao() + { + Loading(isLoading: true); + if (CancelPerfil > 0) + { + SelectedPerfil = ((IEnumerable<Perfil>)Perfis).FirstOrDefault((Func<Perfil, bool>)((Perfil x) => ((DomainBase)x).Id == CancelPerfil)); + } + Alterar(alterar: false); + Loading(isLoading: false); + } + + public async Task Excluir() + { + if (SelectedPerfil == null || ((DomainBase)SelectedPerfil).Id == 0L || !(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return; + } + Loading(isLoading: true); + bool isLast = SelectedPerfil == Perfis.Last(); + if (!(await _servico.Delete(SelectedPerfil))) + { + Loading(isLoading: false); + return; + } + if (isLast) + { + int num = Perfis.IndexOf(SelectedPerfil); + if (num <= 0) + { + await SelecionaPerfis(((DomainBase)_controle).Id, 0L); + } + else + { + await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[num - 1]).Id); + } + } + else if (Perfis.Count > 0) + { + await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[Perfis.IndexOf(SelectedPerfil) + 1]).Id); + } + Loading(isLoading: false); + ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO"); + } +} |