Esempio n. 1
0
        public async Task DeleteAttachment(string id, string attachmentId)
        {
            var idGuid = new Guid(id);
            var userId = _userService.GetProperUserId(User).Value;
            var cipher = await _cipherRepository.GetByIdAsync(idGuid, userId);

            if (cipher == null)
            {
                throw new NotFoundException();
            }

            await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false);
        }
Esempio n. 2
0
        private async void AttachmentSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var attachment = e.SelectedItem as VaultAttachmentsPageModel.Attachment;

            if (attachment == null)
            {
                return;
            }

            ((ListView)sender).SelectedItem = null;

            var confirmed = await DisplayAlert(null, AppResources.DoYouReallyWantToDelete, AppResources.Yes,
                                               AppResources.No);

            if (!confirmed)
            {
                return;
            }

            await _deviceActionService.ShowLoadingAsync(AppResources.Deleting);

            var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id);

            await _deviceActionService.HideLoadingAsync();

            if (saveTask.Succeeded)
            {
                _deviceActionService.Toast(AppResources.AttachmentDeleted);
                _googleAnalyticsService.TrackAppEvent("DeletedAttachment");
                await LoadAttachmentsAsync();
            }
            else if (saveTask.Errors.Count() > 0)
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok);
            }
            else
            {
                await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok);
            }
        }
Esempio n. 3
0
        private async void AttachmentSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var attachment = e.SelectedItem as VaultAttachmentsPageModel.Attachment;

            if (attachment == null)
            {
                return;
            }

            ((ListView)sender).SelectedItem = null;

            if (!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))
            {
                return;
            }

            _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black);
            var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id);

            _userDialogs.HideLoading();

            if (saveTask.Succeeded)
            {
                _userDialogs.Toast(AppResources.AttachmentDeleted);
                _googleAnalyticsService.TrackAppEvent("DeletedAttachment");
                await LoadAttachmentsAsync();
            }
            else if (saveTask.Errors.Count() > 0)
            {
                await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred);
            }
            else
            {
                await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
            }
        }