public ActionResult <bool> DeleteContact(int contactId) { var contactsDAL = new ContactDAL(); var result = contactsDAL.DeleteContact(contactId); return(Ok(result)); }
private void Delete_Button_Click(object sender, RoutedEventArgs e) { if (SelectedContact.Id != 0) { if (MessageBox.Show($"Czy na pewno chcesz usunąć element {SelectedContact.Name} | {SelectedContact.Surname} ?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { if (contactsDAL.DeleteContact(SelectedContact.Id)) { var items = MainTable.ItemsSource.Cast <Contact>().ToList(); var elementToDelete = items.First(x => x.Id == SelectedContact.Id); items.Remove(elementToDelete); MainTable.ItemsSource = items; ClearContactData(); MessageBox.Show("Kontakt usunięto"); } else { MessageBox.Show("Coś poszło nie tak", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } else { MessageBox.Show("Wybierz element z listy do usunięcia"); } }
public void DeleteContact(int id) { try { cDAL.DeleteContact(id); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Delete Contact /// </summary> /// <param name="ContactId">ContactId</param> /// <returns>Returns true if deletion is successful else false</returns> // DELETE: api/Contact/Delete/5 public async Task <bool> DeleteContact(int ContactId) { ContactValidator contactValidator = new ContactValidator(eHIDemoContext); contactValidator.ValidateDeleteContactRequest(ContactId); ContactDAL contactDAL = new ContactDAL(eHIDemoContext); int deletedRecordCount = await contactDAL.DeleteContact(ContactId).ConfigureAwait(false);; if (deletedRecordCount > 0) { return(true); } return(false); }
public int DeleteContact(int cId) { return(_contactDAL.DeleteContact(cId)); }
// http://en.wikipedia.org/wiki/Create,_read,_update_and_delete /// <summary> /// Tar bort specifierad kontaktuppgift ur databasen. /// </summary> /// <param name="contact">Kontaktuppgift som ska tas bort.</param> public void DeleteContact(int contactId) { ContactDAL.DeleteContact(contactId); }
public static void DeleteContact(Contact contact) { ContactDAL.DeleteContact(contact); }