private async void DeleteContact(ContactViewModel contactViewModel)
        {
            if (await _pageService.DisplayAlert("Delete contact", $"Are you sure that you want to delete {contactViewModel.FullName} from your contacts?", "Yes", "Cancel"))
            {
                Contacts.Remove(contactViewModel);
                var contact = await _contactStore.GetContact(contactViewModel.Id);

                await _contactStore.DeleteContact(contact);
            }
        }
Exemplo n.º 2
0
        private async Task DeleteContact(ContactViewModel contactViewModel)
        {
            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete {contactViewModel.FullName}?", "Yes", "No"))
            {
                Contacts.Remove(contactViewModel);
                var contact = await _contactStore.GetContact(contactViewModel.Id);

                await _contactStore.DeleteContact(contact);
            }
        }
        public async Task DeleteContact(ContactViewModel contactViewModel)
        {
            var result = await _pageService.DisplayAlert("Warning", String.Format("Are you sure you want to delete {0}", contactViewModel?.FullName), "Yes", "No");

            if (result)
            {
                Contacts.Remove(contactViewModel);

                var contact = await _contactStore.GetContact(contactViewModel.Id);

                await _contactStore.DeleteContact(contact);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Metodo encargado de eliminar un contacto, mostrando alerta al usuario mediante el servicio de pagina.
        /// </summary>
        /// <param name="contactViewModel">Contacto a eliminar de la BBDD</param>
        /// <returns>Tarea en hilo a parte.</returns>
        private async Task DeleteContact(ContactViewModel contactViewModel)
        {
            var a = "";

            //Si el usuario confirma la eliminacion del contacto
            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete {contactViewModel.FullName}?", "Yes", "No"))
            {
                //Lo eliminamos de la listView
                Contacts.Remove(contactViewModel);

                // Creamos un contacto y lo recogemos de la BBDD para ahorrar memoria para no tenerlo constantemente inicializado,
                // pues si crece mucho la lista de contactos podria desperdiciarse memoria, despues lanzamos la consulta para eliminar de la BBDD el contacto
                var contact = await _contactStore.GetContact(contactViewModel.Id);

                await _contactStore.DeleteContact(contact);
            }
        }
        private async Task DeleteContact(ContactViewModel contactViewModel)
        {
            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete {contactViewModel.FullName}?", "Yes", "No"))
            {
                Contacts.Remove(contactViewModel);

                // We're working with ContactViewModel objects on this page.
                // But to delete a contact, we need a Contact object. Here
                // we're getting the Contact again from the database. Another
                // solution would be to store the Contact objects we initially
                // fetch. But this would require additional memory and as the
                // number of contacts grows, it can take unnecessary amount of
                // memory on the device. So, I prefer to get the contact explicitly
                // here.
                var contact = await _contactStore.GetContact(contactViewModel.Id);

                await _contactStore.DeleteContact(contact);
            }
        }