diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs new file mode 100644 index 0000000..852bedd --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Generic/SelecionarItensViewModel.cs @@ -0,0 +1,89 @@ +using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.ViewModels.Generic
+{
+ public class SelecionarItensViewModel : BaseSegurosViewModel
+ {
+ private ItemServico _itemServico;
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ private bool? _allSelected;
+
+ private bool _allSelectedChanging;
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return this._allSelected;
+ }
+ set
+ {
+ bool? nullable = value;
+ bool? nullable1 = this._allSelected;
+ if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue)
+ {
+ return;
+ }
+ this._allSelected = value;
+ this.AllSelectedChanged();
+ base.OnPropertyChanged("AllSelected");
+ }
+ }
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return this._itens;
+ }
+ set
+ {
+ this._itens = value;
+ base.OnPropertyChanged("Itens");
+ }
+ }
+
+ public SelecionarItensViewModel(long id)
+ {
+ this._itemServico = new ItemServico();
+ this.CarregarItens(id);
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (this._allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ this._allSelectedChanging = true;
+ if (this.AllSelected.HasValue)
+ {
+ foreach (Item iten in this.Itens)
+ {
+ iten.set_Selecionado(this.AllSelected.Value);
+ }
+ }
+ }
+ finally
+ {
+ this._allSelectedChanging = false;
+ }
+ }
+
+ private async void CarregarItens(long id)
+ {
+ this.Itens = await this._itemServico.BuscarItens(id, 0);
+ }
+ }
+}
\ No newline at end of file |