Exemplo n.º 1
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            ListView      listViewPhones = FindViewById <ListView>(Resource.Id.listViewPhones);
            Button        btnDelete      = FindViewById <Button>(Resource.Id.btnDelete);
            PhonesService phonesService  = new PhonesService();

            var confirm = new AlertDialog.Builder(this);

            confirm.SetMessage("Are you sure you want to delete " + selectedPhones.Count + " phones?");
            confirm.SetPositiveButton("Yes", delegate
            {
                for (int i = 0; i < selectedPhones.Count; i++)
                {
                    phonesService.Delete(selectedPhones[i]);
                    MainActivity.SelectedContact.Phones.Remove(selectedPhones[i]);
                }
                var okMessage = new AlertDialog.Builder(this);
                okMessage.SetMessage(selectedPhones.Count + " phones deleted!");
                okMessage.SetPositiveButton("Okay", delegate { });
                okMessage.Show();


                listViewPhones.Adapter = RefreshAdapter();;
                selectedPhones.Clear();
                btnDelete.Enabled = false;
                Recreate();
            });
            confirm.SetNegativeButton("No", delegate { Recreate(); });
            confirm.Show();
        }
Exemplo n.º 2
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(this.RedirectToAction <ContactsController>(c => c.List()));
            }

            PhonesService phonesService = new PhonesService();
            int           contactID     = phonesService.GetContactID(id.Value);

            phonesService.Delete(id.Value);

            return(this.RedirectToAction(c => c.List(), new { ContactID = contactID }));
        }
Exemplo n.º 3
0
        public ActionResult Delete(int?id)
        {
            PhonesService phoneService = new PhonesService();

            if (!id.HasValue)
            {
                return(this.RedirectToAction(c => c.List()));
            }
            else
            {
                phoneService.Delete(id.Value);
            }
            return(this.RedirectToAction(c => c.List()));
        }