示例#1
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem == null)
            {
                popup        = ConfigurePopup.Configure(popup, "Select an item first!", BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
                return;
            }
            try
            {
                var p = await AdminInterface.GetAsync((LvAll.SelectedItem as PictureInfo).Id);

                if (p != null)
                {
                    await Task.Run(() => AdminInterface.RemoveAsync(p));

                    await Task.Run(() => RefreshList());
                }
            }
            catch (Exception ex)
            {
                popup        = ConfigurePopup.Configure(popup, ex.Message, BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
            }
        }
 public static async Task <bool> Remove <T>(IAdminInterface <T> adminInterface, T entity)
 {
     return(await Task.Run(async() =>
     {
         var flag = false;
         await Task.Run(() => { adminInterface.RemoveAsync(entity); });
         flag = true;
         return flag;
     }));
 }
 private async void BtnDelete_Click(object sender, RoutedEventArgs e)
 {
     popup.IsOpen = false;
     if (LvAll.SelectedItem != null)
     {
         try
         {
             Attraction a = LvAll.SelectedItem as Attraction;
             await Task.Run(() => AdminInterface.RemoveAsync(a));
         }
         catch (Exception ex)
         {
             popup        = ConfigurePopup.Configure(popup, ex.Message, BtnDelete, PlacementMode.Bottom);
             popup.IsOpen = true;
         }
     }
     else
     {
         popup        = ConfigurePopup.Configure(popup, "Select item first!", LvAll, PlacementMode.Right);
         popup.IsOpen = true;
     }
 }