Пример #1
0
        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();
        }
Пример #2
0
        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"));
        }
Пример #3
0
        public IActionResult ConfirmDelete(ContactDeleteViewModel contact)
        {
            _contactDatabase.Delete(contact.Id);

            return(RedirectToAction("Contactenoverzicht"));
        }
Пример #4
0
 public IActionResult ConfirmDelete(int id)
 {
     _contactDabase.Delete(id);
     return(RedirectToAction("Index"));
 }
Пример #5
0
 public IActionResult ConfirmDelete([FromRoute] int id)
 {
     _contactDatabase.Delete(id);
     return(RedirectToAction(nameof(Index)));
 }