Exemplo n.º 1
0
        private async void OnDeleteClick()
        {
            IsEnabled = false;
            try
            {
                ContentDialog dialog = new ContentDialog();
                dialog.Title = $"Bent u zeker dat u {Selected.Name} wilt verwijderen?";
                dialog.IsSecondaryButtonEnabled = true;
                dialog.PrimaryButtonText        = "Ja";
                dialog.SecondaryButtonText      = "Nee";
                var result = await dialog.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    Debug.WriteLine(Selected.Id);
                    var success = await entService.DeleteEnterprise(Selected.Id);

                    if (success)
                    {
                        toastService.ShowToast("Onderneming verwijderd", "");

                        Source.Clear();
                        _entlist = await entService.GetEnterprisesByOwner();

                        _entlist.ForEach(ent => { Source.Add(ent); });
                        if (Source.Count > 0)
                        {
                            Selected = Source.First();
                        }
                    }
                    else
                    {
                        toastService.ShowToast("Onderneming niet verwijderd", "probeer later opnieuw");
                    }
                }
            } catch (Exception)
            {
                toastService.ShowToast("Er ging iets mis", "probeer later opnieuw");
            }
            IsEnabled = true;
        }