private void DeleteItem_Click(object sender, RoutedEventArgs e) { // click var etLink = (RememberUtility.Model.Entertainment)listviewEt.SelectedItem; if (MessageBox.Show($"Found '{etLink.EnterName}'." + $" Do you wanna delete '{etLink.EnterName}'", "Confirm delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { entertainmentUtil.DeleteEntertainment(etLink.EnterName); lblResultStatus.Foreground = Brushes.Green; lblResultStatus.Content = "Deleted"; // Count second var stopwatch = new Stopwatch(); stopwatch.Restart(); // Count this object loading listviewEt.ItemsSource = entertainmentUtil.GetListEntertainments(); Show_ms.Content = stopwatch.Elapsed.TotalMilliseconds; // Count again ListObjectEt.Foreground = Brushes.ForestGreen; ListObjectEt.Content = entertainmentUtil.GetListEntertainments().Count; stopwatch.Stop(); } else { lblResultStatus.Foreground = Brushes.Red; lblResultStatus.Content = "Canceled"; } }
private void Delete_Click(object sender, RoutedEventArgs e) { var et = new RememberUtility.Model.Entertainment(); // txtEtName if (txtEtName.Text != "") { et.EnterName = txtEtName.Text; } else { AddEtResult.Foreground = Brushes.Red; AddEtResult.Content = "Et name cannot be null. Please choose a type"; } if (txtEtName.Text == "") { AddEtResult.Foreground = Brushes.Red; AddEtResult.Content = "You must input Et name"; } else // has input { var findEt = entertainmentUtil.FindEntertainmentBy(txtEtName.Text); if (findEt != null) { if (et.EnterName.ToLower() == findEt.EnterName.ToLower()) { if (MessageBox.Show($"Found '{txtEtName.Text}'." + $" Do you wanna delete '{txtEtName.Text}'", "Confirm delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { entertainmentUtil.DeleteEntertainment(et.EnterName); AddEtResult.Foreground = Brushes.Green; AddEtResult.Content = $"Delete '{txtEtName.Text}' Successful"; txtEtName.Text = string.Empty; txtLink.Text = string.Empty; txtAuthorEnter.Text = string.Empty; lstListEtCategory.Text = string.Empty; } else { AddEtResult.Foreground = Brushes.YellowGreen; AddEtResult.Content = $"Delete operate was canceled."; } } } // input and not found else { AddEtResult.Foreground = Brushes.Red; AddEtResult.Content = $" Cannot find '{txtEtName.Text}'. Delete failed."; } } }
public ActionResult DeleteConfirmed(string id) { var entertainment = _entertainmentUtil.FindEntertainmentByEnterId(id); if (entertainment == null) { return(View("Error")); } _entertainmentUtil.DeleteEntertainment(entertainment.EnterName); return(RedirectToAction("Index", "Entertainment")); }