summaryrefslogtreecommitdiff
path: root/Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
commit674ca83ba9243a9e95a7568c797668dab6aee26a (patch)
tree4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs
downloadgestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz
gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip
feat: upload files
Diffstat (limited to 'Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs')
-rw-r--r--Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs147
1 files changed, 147 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs b/Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs
new file mode 100644
index 0000000..e62f957
--- /dev/null
+++ b/Gestor.Application/ViewModels/Financeiro/PlanoViewModel.cs
@@ -0,0 +1,147 @@
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.ViewModels.Financeiro
+{
+ public class PlanoViewModel : BaseFinanceiroViewModel
+ {
+ private readonly PlanoServico _planoServico;
+
+ private Plano _selectedPlano;
+
+ public Plano Cancel;
+
+ public Plano SelectedPlano
+ {
+ get
+ {
+ return this._selectedPlano;
+ }
+ set
+ {
+ long? nullable;
+ this._selectedPlano = value;
+ if (value != null)
+ {
+ nullable = new long?(value.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ }
+ base.VerificarEnables(nullable);
+ base.OnPropertyChanged("SelectedPlano");
+ }
+ }
+
+ public PlanoViewModel(Plano plano)
+ {
+ this._planoServico = new PlanoServico();
+ this.Seleciona(plano);
+ }
+
+ public void Cancelar()
+ {
+ base.Loading(true);
+ if (this.SelectedPlano.get_Id() != 0)
+ {
+ base.Alterar(false);
+ base.Loading(false);
+ return;
+ }
+ this.SelectedPlano = new Plano();
+ base.Alterar(false);
+ base.Loading(false);
+ }
+
+ public void Incluir()
+ {
+ Plano plano = new Plano();
+ plano.set_Ativo(true);
+ this.SelectedPlano = plano;
+ base.Alterar(true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedPlano.Validate();
+ List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
+ keyValuePairs2.AddRange(await this.Validate());
+ keyValuePairs2 = null;
+ if (keyValuePairs1.Count <= 0)
+ {
+ this.SelectedPlano = await this._planoServico.Save(this.SelectedPlano);
+ if (this._planoServico.Sucesso)
+ {
+ base.Alterar(false);
+ base.ToggleSnackBar("PLANO SALVO COM SUCESSO", true);
+ keyValuePairs = null;
+ }
+ else
+ {
+ keyValuePairs = null;
+ }
+ }
+ else
+ {
+ keyValuePairs = keyValuePairs1;
+ }
+ keyValuePairs1 = null;
+ return keyValuePairs;
+ }
+
+ private async void Seleciona(Plano plano)
+ {
+ base.Loading(true);
+ await base.PermissaoTela(27);
+ if (plano != null)
+ {
+ this.SelectedPlano = plano;
+ }
+ else
+ {
+ Plano plano1 = new Plano();
+ plano1.set_Descricao("");
+ plano1.set_Ativo(true);
+ this.SelectedPlano = plano1;
+ }
+ base.Loading(false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
+ bool flag = true;
+ List<Plano> planos = await (new BaseServico()).BuscarPlanoAsync();
+ if (planos.Count > 0)
+ {
+ planos.ForEach((Plano x) => {
+ if (x.get_Id() == this.SelectedPlano.get_Id())
+ {
+ return;
+ }
+ if (x.get_Descricao() == this.SelectedPlano.get_Descricao())
+ {
+ flag = false;
+ }
+ });
+ }
+ if (!flag)
+ {
+ keyValuePairs.Add(new KeyValuePair<string, string>("Descricao", "UM PLANO COM ESSE NOME JÁ EXISTE."));
+ }
+ List<KeyValuePair<string, string>> keyValuePairs1 = keyValuePairs;
+ keyValuePairs = null;
+ return keyValuePairs1;
+ }
+ }
+} \ No newline at end of file