From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs | 281 +++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs new file mode 100644 index 0000000..8ee9f0b --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs @@ -0,0 +1,281 @@ +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; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows.Controls; + +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 _agger; + + private ObservableCollection _aggerFiltrado; + + private List _aggilizador; + + public List Agger + { + get + { + return this._agger; + } + set + { + this._agger = value; + base.OnPropertyChanged("Agger"); + } + } + + public ObservableCollection AggerFiltrado + { + get + { + return this._aggerFiltrado; + } + set + { + this._aggerFiltrado = value; + base.OnPropertyChanged("AggerFiltrado"); + } + } + + public List Aggilizador + { + get + { + return this._aggilizador; + } + set + { + this._aggilizador = value; + base.OnPropertyChanged("Aggilizador"); + } + } + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + base.OnPropertyChanged("Carregando"); + } + } + + public bool EnableExclusao + { + get + { + return this._enableExclusao; + } + set + { + this._enableExclusao = value; + base.OnPropertyChanged("EnableExclusao"); + } + } + + public string InfoAggilizador + { + get + { + return this._infoAggilizador; + } + set + { + this._infoAggilizador = value; + base.OnPropertyChanged("InfoAggilizador"); + } + } + + public string InfoGestor + { + get + { + return this._infoGestor; + } + set + { + this._infoGestor = value; + base.OnPropertyChanged("InfoGestor"); + } + } + + public AutoCompleteFilterPredicate InstalacaoItemFilter + { + get + { + AutoCompleteFilterPredicate u003cu003e9_370 = InstalacaoViewModel.u003cu003ec.u003cu003e9__37_0; + if (u003cu003e9_370 == null) + { + u003cu003e9_370 = new AutoCompleteFilterPredicate(InstalacaoViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { + if (((Gestor.Application.Model.Ajuda.Instalacao)obj).Maquina.ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Application.Model.Ajuda.Instalacao)obj).Usuario.ToUpper().Contains(searchText.ToUpper())) + { + return true; + } + return ((Gestor.Application.Model.Ajuda.Instalacao)obj).DataIntalacao.ToString().Contains(searchText.ToUpper()); + }); + InstalacaoViewModel.u003cu003ec.u003cu003e9__37_0 = u003cu003e9_370; + } + return u003cu003e9_370; + } + } + + public bool MostrarAggilizador + { + get + { + return this._mostrarAggilizador; + } + set + { + this._mostrarAggilizador = value; + base.OnPropertyChanged("MostrarAggilizador"); + } + } + + public InstalacaoViewModel() + { + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + id = usuario.get_Id() > (long)0; + } + else + { + id = false; + } + this._enableExclusao = id; + base(); + bool id; + this._ajudaServico = new AjudaServico(); + this.LoadInstalacoes(); + } + + public async void Excluir(long id) + { + if (await this._ajudaServico.ExcluirInstalacao(id)) + { + this.LoadInstalacoes(); + } + } + + internal async Task> Filtrar(string value) + { + List instalacaos = await Task.Run>(() => this.FiltrarInstalacao(value)); + return instalacaos; + } + + public List FiltrarInstalacao(string filter) + { + this.AggerFiltrado = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(this.Agger) : new ObservableCollection(this.Agger.Where((Gestor.Application.Model.Ajuda.Instalacao x) => { + if (ValidationHelper.RemoveDiacritics(x.Maquina.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Usuario.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))) + { + return true; + } + return x.DataIntalacao.ToString().Contains(ValidationHelper.RemoveDiacritics(filter)); + }))); + return this.AggerFiltrado.ToList(); + } + + private async void LoadInstalacoes() + { + int? nullable; + List instalacaos; + int? nullable1; + int? nullable2; + string str; + this.Carregando = true; + ObservableCollection observableCollection = await this._ajudaServico.BuscarLicencas(); + InstalacaoViewModel list = this; + ObservableCollection observableCollection1 = observableCollection; + list.Agger = ( + from x in observableCollection1 + where !string.IsNullOrEmpty(x.IdGerenciador) + select x).ToList(); + this.AggerFiltrado = new ObservableCollection(this.Agger); + InstalacaoViewModel instalacaoViewModel = this; + List produtos = LicenseHelper.Produtos; + if (produtos.Any((Licenca x) => x.get_Produto() == 81)) + { + instalacaos = new List(); + } + else + { + ObservableCollection observableCollection2 = observableCollection; + instalacaos = ( + from x in observableCollection2 + where !string.IsNullOrEmpty(x.IdAggilizador) + select x).ToList(); + } + instalacaoViewModel.Aggilizador = instalacaos; + InstalacaoViewModel instalacaoViewModel1 = this; + object count = this.Agger.Count; + List licencas = LicenseHelper.Produtos; + Licenca licenca = licencas.FirstOrDefault((Licenca x) => x.get_Produto() == 1); + if (licenca != null) + { + nullable1 = new int?(licenca.get_Quantidade()); + } + else + { + nullable = null; + nullable1 = nullable; + } + instalacaoViewModel1.InfoGestor = string.Format("{0} LICENÇAS INSTALADAS DE {1} LICENÇAS CONTRATADAS.", count, nullable1); + InstalacaoViewModel instalacaoViewModel2 = this; + if (this.Aggilizador.Count > 0) + { + object obj = this.Aggilizador.Count; + List produtos1 = LicenseHelper.Produtos; + Licenca licenca1 = produtos1.FirstOrDefault((Licenca x) => x.get_Produto() == 81); + if (licenca1 != null) + { + nullable2 = new int?(licenca1.get_Quantidade()); + } + else + { + nullable = null; + nullable2 = nullable; + } + str = string.Format("{0} LICENÇAS INSTALADAS DE {1} LICENÇAS CONTRATADAS.", obj, nullable2); + } + else + { + str = ""; + } + instalacaoViewModel2.InfoAggilizador = str; + this.MostrarAggilizador = this.Aggilizador.Count > 0; + this.Carregando = false; + } + } +} \ No newline at end of file -- cgit v1.2.3