blob: 6e0bd14a57702c80021c02618020bee28a8c2297 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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<Item> _itens = new ObservableCollection<Item>();
private bool? _allSelected;
private bool _allSelectedChanging;
public ObservableCollection<Item> 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;
}
}
}
|