summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs129
1 files changed, 129 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
new file mode 100644
index 0000000..4218195
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
@@ -0,0 +1,129 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class PlanoViewModel : BaseFinanceiroViewModel
+{
+ private readonly PlanoServico _planoServico;
+
+ private Plano _selectedPlano;
+
+ public Plano Cancel;
+
+ public Plano SelectedPlano
+ {
+ get
+ {
+ return _selectedPlano;
+ }
+ set
+ {
+ _selectedPlano = value;
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedPlano");
+ }
+ }
+
+ public PlanoViewModel(Plano plano)
+ {
+ _planoServico = new PlanoServico();
+ Seleciona(plano);
+ }
+
+ private async void Seleciona(Plano plano)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)27);
+ if (plano == null)
+ {
+ SelectedPlano = new Plano
+ {
+ Descricao = "",
+ Ativo = true
+ };
+ }
+ else
+ {
+ SelectedPlano = plano;
+ }
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedPlano.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedPlano = await _planoServico.Save(SelectedPlano);
+ if (!_planoServico.Sucesso)
+ {
+ return null;
+ }
+ Alterar(alterar: false);
+ ToggleSnackBar("PLANO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void Cancelar()
+ {
+ //IL_0015: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Expected O, but got Unknown
+ Loading(isLoading: true);
+ if (((DomainBase)SelectedPlano).Id == 0L)
+ {
+ SelectedPlano = new Plano();
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+ else
+ {
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ List<Plano> list = await new BaseServico().BuscarPlanoAsync();
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(Plano x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedPlano).Id && x.Descricao == SelectedPlano.Descricao)
+ {
+ valida = false;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Descricao", "UM PLANO COM ESSE NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ public void Incluir()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0012: Expected O, but got Unknown
+ SelectedPlano = new Plano
+ {
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+}