summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs201
1 files changed, 201 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs
new file mode 100644
index 0000000..bfe29e1
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Drawer.Ajuda/InstalacaoViewModel.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model.Ajuda;
+using Gestor.Application.Servicos.Ajuda;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+
+namespace Gestor.Application.ViewModels.Drawer.Ajuda;
+
+public class InstalacaoViewModel : BaseViewModel
+{
+ private readonly AjudaServico _ajudaServico;
+
+ private bool _enableExclusao;
+
+ private bool _mostrarAggilizador;
+
+ private string _infoGestor;
+
+ private string _infoAggilizador;
+
+ private bool _carregando;
+
+ private List<Instalacao> _agger;
+
+ private ObservableCollection<Instalacao> _aggerFiltrado;
+
+ private List<Instalacao> _aggilizador;
+
+ public bool EnableExclusao
+ {
+ get
+ {
+ return _enableExclusao;
+ }
+ set
+ {
+ _enableExclusao = value;
+ OnPropertyChanged("EnableExclusao");
+ }
+ }
+
+ public bool MostrarAggilizador
+ {
+ get
+ {
+ return _mostrarAggilizador;
+ }
+ set
+ {
+ _mostrarAggilizador = value;
+ OnPropertyChanged("MostrarAggilizador");
+ }
+ }
+
+ public string InfoGestor
+ {
+ get
+ {
+ return _infoGestor;
+ }
+ set
+ {
+ _infoGestor = value;
+ OnPropertyChanged("InfoGestor");
+ }
+ }
+
+ public string InfoAggilizador
+ {
+ get
+ {
+ return _infoAggilizador;
+ }
+ set
+ {
+ _infoAggilizador = value;
+ OnPropertyChanged("InfoAggilizador");
+ }
+ }
+
+ public bool Carregando
+ {
+ get
+ {
+ return _carregando;
+ }
+ set
+ {
+ _carregando = value;
+ base.IsEnabled = !value;
+ base.EnableMenu = !value;
+ OnPropertyChanged("Carregando");
+ }
+ }
+
+ public List<Instalacao> Agger
+ {
+ get
+ {
+ return _agger;
+ }
+ set
+ {
+ _agger = value;
+ OnPropertyChanged("Agger");
+ }
+ }
+
+ public ObservableCollection<Instalacao> AggerFiltrado
+ {
+ get
+ {
+ return _aggerFiltrado;
+ }
+ set
+ {
+ _aggerFiltrado = value;
+ OnPropertyChanged("AggerFiltrado");
+ }
+ }
+
+ public List<Instalacao> Aggilizador
+ {
+ get
+ {
+ return _aggilizador;
+ }
+ set
+ {
+ _aggilizador = value;
+ OnPropertyChanged("Aggilizador");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> InstalacaoItemFilter => (string searchText, object obj) => ((Instalacao)obj).Maquina.ToUpper().Contains(searchText.ToUpper()) || ((Instalacao)obj).Usuario.ToUpper().Contains(searchText.ToUpper()) || ((Instalacao)obj).DataIntalacao.ToString().Contains(searchText.ToUpper());
+
+ public InstalacaoViewModel()
+ {
+ Usuario usuario = Recursos.Usuario;
+ _enableExclusao = usuario != null && ((DomainBase)usuario).Id > 0;
+ base._002Ector();
+ _ajudaServico = new AjudaServico();
+ LoadInstalacoes();
+ }
+
+ private async void LoadInstalacoes()
+ {
+ Carregando = true;
+ ObservableCollection<Instalacao> source = await _ajudaServico.BuscarLicencas();
+ Agger = source.Where((Instalacao x) => !string.IsNullOrEmpty(x.IdGerenciador)).ToList();
+ AggerFiltrado = new ObservableCollection<Instalacao>(Agger);
+ Aggilizador = (LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 81) ? new List<Instalacao>() : source.Where((Instalacao x) => !string.IsNullOrEmpty(x.IdAggilizador)).ToList());
+ InstalacaoViewModel instalacaoViewModel = this;
+ object arg = Agger.Count;
+ Licenca? obj = ((IEnumerable<Licenca>)LicenseHelper.Produtos).FirstOrDefault((Func<Licenca, bool>)((Licenca x) => (int)x.Produto == 1));
+ instalacaoViewModel.InfoGestor = $"{arg} LICENÇAS INSTALADAS DE {((obj != null) ? new int?(obj.Quantidade) : null)} LICENÇAS CONTRATADAS.";
+ InstalacaoViewModel instalacaoViewModel2 = this;
+ object infoAggilizador;
+ if (Aggilizador.Count <= 0)
+ {
+ infoAggilizador = "";
+ }
+ else
+ {
+ object arg2 = Aggilizador.Count;
+ Licenca? obj2 = ((IEnumerable<Licenca>)LicenseHelper.Produtos).FirstOrDefault((Func<Licenca, bool>)((Licenca x) => (int)x.Produto == 81));
+ infoAggilizador = $"{arg2} LICENÇAS INSTALADAS DE {((obj2 != null) ? new int?(obj2.Quantidade) : null)} LICENÇAS CONTRATADAS.";
+ }
+ instalacaoViewModel2.InfoAggilizador = (string)infoAggilizador;
+ MostrarAggilizador = Aggilizador.Count > 0;
+ Carregando = false;
+ }
+
+ public async void Excluir(long id)
+ {
+ if (await _ajudaServico.ExcluirInstalacao(id))
+ {
+ LoadInstalacoes();
+ }
+ }
+
+ internal async Task<List<Instalacao>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarInstalacao(value));
+ }
+
+ public List<Instalacao> FiltrarInstalacao(string filter)
+ {
+ AggerFiltrado = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Instalacao>(Agger) : new ObservableCollection<Instalacao>(Agger.Where((Instalacao x) => ValidationHelper.RemoveDiacritics(x.Maquina.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Usuario.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || x.DataIntalacao.ToString().Contains(ValidationHelper.RemoveDiacritics(filter)))));
+ return AggerFiltrado.ToList();
+ }
+}