Exemplo n.º 1
0
        public IActionResult DeleteContact([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var removed = _contactRepo.DeleteContact(id);

            return((removed == null) ? (IActionResult)NotFound() : Ok(removed));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public ActionResult <Contact> DeleteContact(Contact contact)
        {
            var ContactFromRepo = _contactRepo.GetContact(contact.Id);

            if (ContactFromRepo == null)
            {
                return(NotFound());
            }

            _contactRepo.DeleteContact(contact);

            return(NoContent());
        }
Exemplo n.º 4
0
        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();
            }
        }