コード例 #1
0
        protected override async void OnItemDeletedAsync(object obj)
        {
            Shop shop = obj as Shop;

            if (shop.Status == ShopStatus.Approved)
            {
                await Page.DisplayAlert($"کێشەیەک ڕوویدا", $"ناتوانیت ئەم تۆمارە بسڕیتەوە لەبەرئەوەی پەسەندکراوە.", "باشە");

                return;
            }
            bool shouldDelete = await Page.DisplayAlert($"Delete {shop.KurdishName}", $"Are you sure you want to delete {shop.KurdishName}?", "Yes", "No");

            if (shouldDelete)
            {
                await DataManager.Default.ShopTable.DeleteAsync(shop);

                foreach (var album in await DataManager.Default.AlbumTable.Where(a => a.ShopID == shop.ID).ToEnumerableAsync())
                {
                    foreach (var image in await DataManager.Default.AlbumImageTable.Where(a => a.AlbumID == album.ID).ToEnumerableAsync())
                    {
                        await DataManager.Default.AlbumImageTable.DeleteAsync(image);
                    }

                    await DataManager.Default.AlbumTable.DeleteAsync(album);
                }
                foreach (var subCat in await DataManager.Default.ShopSubcategoryTable.Where(s => s.ShopID == shop.ID).ToEnumerableAsync())
                {
                    await DataManager.Default.ShopSubcategoryTable.DeleteAsync(subCat);
                }
                OnRefresh.Execute(null);
            }
        }