private async Task DeleteStorage(StorageViewModel storageViewModel)
        {
            if (await this.pageService.DisplayAlert("Warning", $"Are you sure you want to delete {storageViewModel}?", "Yes", "No"))
            {
                Storages.Remove(storageViewModel);

                var storage = await this.storageStore.GetStorage(storageViewModel.Id);

                await this.storageStore.DeleteStorage(storage);
            }
        }
Esempio n. 2
0
        private async Task Delete(StorageViewModel storageViewModel)
        {
            if (await this.pageService.DisplayAlert("Warning", $"Are you sure you want to delete {storageViewModel.StorageName}?", "Yes", "No"))
            {
                var storageType = await this.storageStore.GetStorage(storageViewModel.Id);

                StorageDeleted?.Invoke(this, storageViewModel);
                await this.storageStore.DeleteStorage(storageType);

                await this.pageService.PopAsync();
            }
        }
Esempio n. 3
0
        public StorageTypeDetailViewModel(StorageViewModel viewModel, BaseStorageStore storageStore, IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            this.pageService  = pageService;
            this.storageStore = storageStore;

            this.SaveCommand   = new Command(async() => await Save());
            this.DeleteCommand = new Command <StorageViewModel>(async c => await Delete(viewModel));

            this.Storage = new Storage
            {
                Id           = viewModel.Id,
                StorageName  = viewModel.StorageName,
                Url          = viewModel.Url,
                DateAdded    = viewModel.DateAdded,
                DateModified = viewModel.DateModified
            };
        }
        private async Task SelectStorage(StorageViewModel storageType)
        {
            if (storageType == null)
            {
                return;
            }

            SelectedStorage = null;

            var viewModel = new StorageTypeDetailViewModel(storageType, this.storageStore, this.pageService);

            viewModel.StorageUpdated += (source, updatedStorage) =>
            {
                storageType.Id           = updatedStorage.Id;
                storageType.StorageName  = updatedStorage.StorageName;
                storageType.Url          = updatedStorage.Url;
                storageType.DateAdded    = updatedStorage.DateAdded;
                storageType.DateModified = updatedStorage.DateModified;
            };

            await this.pageService.PushAsync(new StorageTypeDetailView(viewModel));
        }