From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../SelecionarItensViewModel.cs | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs new file mode 100644 index 0000000..6e0bd14 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs @@ -0,0 +1,82 @@ +using System.Collections.ObjectModel; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Model.Common; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Generic; + +public class SelecionarItensViewModel : BaseSegurosViewModel +{ + private ItemServico _itemServico; + + private ObservableCollection _itens = new ObservableCollection(); + + private bool? _allSelected; + + private bool _allSelectedChanging; + + public ObservableCollection Itens + { + get + { + return _itens; + } + set + { + _itens = value; + OnPropertyChanged("Itens"); + } + } + + public bool? AllSelected + { + get + { + return _allSelected; + } + set + { + if (value != _allSelected) + { + _allSelected = value; + AllSelectedChanged(); + OnPropertyChanged("AllSelected"); + } + } + } + + public SelecionarItensViewModel(long id) + { + _itemServico = new ItemServico(); + CarregarItens(id); + } + + private async void CarregarItens(long id) + { + Itens = await _itemServico.BuscarItens(id, (StatusItem)0); + } + + private void AllSelectedChanged() + { + if (_allSelectedChanging) + { + return; + } + try + { + _allSelectedChanging = true; + if (!AllSelected.HasValue) + { + return; + } + foreach (Item iten in Itens) + { + iten.Selecionado = AllSelected.Value; + } + } + finally + { + _allSelectedChanging = false; + } + } +} -- cgit v1.2.3