private void OnContactDelete(object sender, EventArgs e) { var selected = GetSelectedContact(); if (selected == null) { return; } //Display confirmation if (MessageBox.Show(this, $"Are you sure you want to delete {selected.Name}?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } try { _contacts.Delete(selected.Id); } catch (Exception ex) { DisplayError(ex); }; BindList(); }
public IActionResult ConfirmDelete(int id) { Contact contact = _contactDatabase.GetContact(id); if (!string.IsNullOrEmpty(contact.PhotoUrl)) { var prevPath = Path.Combine(_hostEnvironment.WebRootPath, "photos", contact.PhotoUrl.Substring(8)); System.IO.File.Delete(prevPath); } _contactDatabase.Delete(id); return(RedirectToAction("Index")); }
public IActionResult ConfirmDelete(ContactDeleteViewModel contact) { _contactDatabase.Delete(contact.Id); return(RedirectToAction("Contactenoverzicht")); }
public IActionResult ConfirmDelete(int id) { _contactDabase.Delete(id); return(RedirectToAction("Index")); }
public IActionResult ConfirmDelete([FromRoute] int id) { _contactDatabase.Delete(id); return(RedirectToAction(nameof(Index))); }