private void BtnDelete_Click(object sender, EventArgs e) { var confirm = new AlertDialog.Builder(this); confirm.SetMessage("Are you sure you want to delete " + selectedContacts.Count + " contacts?"); confirm.SetPositiveButton("Yes", delegate { ContactsService contactsService = new ContactsService(); Button btnDelete = FindViewById <Button>(Resource.Id.btnDelete); for (int i = 0; i < selectedContacts.Count; i++) { contactsService.Delete(selectedContacts[i]); AuthenticationService.LoggedUser.Contacts.Remove(selectedContacts[i]); } var okMessage = new AlertDialog.Builder(this); okMessage.SetMessage(selectedContacts.Count + " contacts deleted!"); okMessage.SetPositiveButton("Okay", delegate { }); okMessage.Show(); ListView listViewContacts = FindViewById <ListView>(Resource.Id.listViewContacts); listViewContacts.Adapter = RefreshAdapter(); selectedContacts.Clear(); btnDelete.Enabled = false; Recreate(); }); confirm.SetNegativeButton("No", delegate { Recreate(); }); confirm.Show(); }
public ActionResult DeleteContacts(int project, int id) { ViewBag.Projects = Projectservice.Get(); ContactsService.Delete(id); ViewBag.ProjectId = project; return(RedirectToAction("Index", new { Projects = ViewBag.ProjectId })); }
public ActionResult Contacts_Destroy([DataSourceRequest] DataSourceRequest request, ContactViewModel contact) { if (contact != null) { contactsService.Delete(contact); } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Delete(string id) { var contact = _contactsService.Get(id); if (contact == null) { return(NotFound()); } _contactsService.Delete(id); return(Ok()); }
public ActionResult Delete(int?id) { ContactsService contactService = new ContactsService(); if (!id.HasValue) { return(this.RedirectToAction(c => c.List())); } else { contactService.Delete(id.Value); } return(this.RedirectToAction(c => c.List())); }
public void DeleteNotFoundTest() { //arrange _mockContactsRepo.Setup(r => r.FindOne(It.IsAny <int>())); var service = new ContactsService(_mockContactsRepo.Object, _mockContactsMapper.Object); //act var actual = service.Delete(1); //assert _mockContactsRepo.Verify(mock => mock.Delete(It.IsAny <int>()), Times.Never()); }
public ActionResult Delete(int?id) { if (!id.HasValue) { return(this.RedirectToAction(c => c.List())); } UnitOfWork unitOfWork = new UnitOfWork(); ContactsService contactsService = new ContactsService(unitOfWork); contactsService.GetByID(id.Value).Groups.Clear(); contactsService.Delete(id.Value); return(this.RedirectToAction(c => c.List())); }
public void DeleteHappyPathTest() { //arrange _mockContactsRepo.Setup(r => r.FindOne(It.IsAny <int>())).Returns(contactsEntity); _mockContactsRepo.Setup(r => r.Delete(It.IsAny <int>())).Returns(1); var service = new ContactsService(_mockContactsRepo.Object, _mockContactsMapper.Object); //act var actual = service.Delete(1); //assert Assert.IsNotNull(actual); Assert.AreEqual(1, actual); _mockContactsRepo.Verify(mock => mock.Delete(1), Times.Once()); }