/// <summary>
        /// Delete a contact.
        /// </summary>
        /// <param name="id">Contact ID.</param>
        /// <returns>The deleted contact.</returns>
        public Contact Delete(int id)
        {
            var deleted = contactStore.Get(id);

            if (deleted == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            contactStore.Delete(id);
            return(deleted);
        }
Пример #2
0
        private async Task DeleteContact(ContactViewModel contact)
        {
            if (await _pageService.DisplayAlert(
                    "Delete contact?",
                    $"Are you sure you want to delete {contact.FullName}",
                    "Yes",
                    "No"))
            {
                Contacts.Remove(contact);
            }

            var contactInDb = await _contactStore.Get(contact.Id);

            await _contactStore.Delete(contactInDb.Id);
        }