Beispiel #1
0
        public async Task Remove()
        {
            var result = await _dialogService.ShowConfirmationMessageAsync(
                L(nameof(Resources.Dialog_AreYouSureTitle)),
                L(nameof(Resources.Dialog_AreYourSureRemoveSourceMessage), _originalId));

            if (result == MessageDialogResult.Affirmative)
            {
                await _progressService.StartLoading(L(nameof(Resources.SettingsViewModel_RemovingSource)));

                try
                {
                    await _chocolateyService.RemoveSource(_originalId);

                    Sources.Remove(SelectedSource);
                    SelectedSource = null;
                    await _eventAggregator.PublishOnUIThreadAsync(new SourcesUpdatedMessage());
                }
                catch (UnauthorizedAccessException)
                {
                    await _dialogService.ShowMessageAsync(
                        L(nameof(Resources.General_UnauthorisedException_Title)),
                        L(nameof(Resources.General_UnauthorisedException_Description)));
                }
                finally
                {
                    await _progressService.StopLoading();
                }
            }
        }
Beispiel #2
0
        public async void Remove()
        {
            await _progressService.StartLoading(Resources.SettingsViewModel_RemovingSource);

            try
            {
                await _chocolateyService.RemoveSource(_originalId);

                Sources.Remove(SelectedSource);
                SelectedSource = null;
                await _eventAggregator.PublishOnUIThreadAsync(new SourcesUpdatedMessage());
            }
            catch (UnauthorizedAccessException)
            {
                await _progressService.ShowMessageAsync(
                    Resources.General_UnauthorisedException_Title,
                    Resources.General_UnauthorisedException_Description);
            }
            finally
            {
                await _progressService.StopLoading();
            }
        }