Ejemplo n.º 1
0
        private async void btnAddResident_Click(object sender, RoutedEventArgs e)
        {
            AddResidentDialog dlg = new AddResidentDialog(_home.ResidentCollection.Count);

            dlg.MinWidth = Window.Current.Bounds.Width * 0.8;
            dlg.MaxWidth = Window.Current.Bounds.Width * 0.8;
            var result = await dlg.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                _home.AddResident(dlg.residentViewModel);
                await _home.dataset.SaveToFolder();
            }
        }
Ejemplo n.º 2
0
        private async void btnAddResident_ClickAsync(object sender, RoutedEventArgs e)
        {
            HashSet <string> existingResidentNames = new HashSet <string>();

            foreach (ResidentViewModel resident in _viewModel.ResidentCollectionView)
            {
                existingResidentNames.Add(resident.Name);
            }
            AddResidentDialog dlg = new AddResidentDialog(existingResidentNames)
            {
                Width = Window.Current.Bounds.Width * 0.8
            };
            var result = await dlg.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                await _viewModel.AddNewResidentAsync(dlg.ResidentViewModel);
            }
        }