public IActionResult DeleteContact([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var removed = _contactRepo.DeleteContact(id); return((removed == null) ? (IActionResult)NotFound() : Ok(removed)); }
public async Task <IHttpActionResult> DeleteContact(int id) { if (!ModelState.IsValid) { // return bad request with validation massage. return(BadRequest(ModelState)); } var contact = await _contactInfo.DeleteContact(id); return(Ok(contact)); }
public ActionResult <Contact> DeleteContact(Contact contact) { var ContactFromRepo = _contactRepo.GetContact(contact.Id); if (ContactFromRepo == null) { return(NotFound()); } _contactRepo.DeleteContact(contact); return(NoContent()); }
private async void DeleteContact(object obj) { var settings = new MetroDialogSettings() { AffirmativeButtonText = "Yes", NegativeButtonText = "No" }; var result = await metroWindow.ShowMessageAsync("Delete Contact", $"Are you sure you want to delete {SelectedContact.FirstName}'s contact details?", MessageDialogStyle.AffirmativeAndNegative, settings); if (result == MessageDialogResult.Affirmative) { await repository.DeleteContact(SelectedContact); LoadDb(); } }