/// <summary> /// Delete the With Attach Entiy. /// </summary> /// <param name="Entiy">The Entiy.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> public bool DeleteWithAttachEntiy(ContactDto t) { var dbEntity = typeAdapter.ConvertDtoToEntities(t); entiesrepository.Attach(dbEntity); entiesrepository.Delete(dbEntity); entiesrepository.Save(); return(true); }
public ActionResult DeleteConfirmed(int id) { Contact contact = repo.SingleOrDefault(id); repo.Delete(contact); return(RedirectToAction("Index")); }
public void Delete(Contact model) { if (!User.Identity.IsAuthenticated) { Response.End(); } var id = model.ContactId; var contact = contactrepo.GetContactById(id); try { contactrepo.Delete(contact); contactrepo.Save();//persist change //make sure that client side knows we don't have errors var newmodel = helper.ToDictModel(contact); newmodel.Add("isError", false); Response.Write(serializer.Serialize(newmodel)); Response.End(); } catch (Exception ex) { var dictmodel = helper.ToDictModel(contact); dictmodel.Add("isError", ex.Message); Response.Write(serializer.Serialize(dictmodel)); Response.End(); } }
public void TearDown() { var repository = new ContactRepository(); var contacts = repository.LoadAll(); contacts.ForEach(x => repository.Delete(x.Id)); }
public async Task Arrange() { MappingBootstrapper.Initialize(); var userNameToFind = "NotFoundUser"; var contacts = new List <Contact> { Builder <Contact> .CreateNew() .With(q => q.Username = userNameToFind) .Build() }.AsQueryable(); var mockSet = contacts.CreateMockSet(contacts); var mockDbContext = CreateMockDbContext(mockSet); var contactRepository = new ContactRepository(mockDbContext.Object, new Mock <IUnitOfWork>().Object); try { await contactRepository.Delete("testuser"); } catch (Exception exception) { _exception = exception; } }
public ActionResult DeleteConfirmed(int id) { Contact contact = ContactRepository.GetSingle(id); try { ContactRepository.Delete(contact); ContactRepository.Save(); if (IsSuperAdmin) { return(RedirectToAction("Index", new { storeId = contact.StoreId })); } else { return(RedirectToAction("Index")); } } catch (Exception ex) { Logger.Error(ex, "Unable to delete:" + ex.StackTrace, contact); //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(contact)); }
public ActionResult DeleteOption(int id) { ContactRepository Repo = new ContactRepository(); Repo.Delete(id); return(Ok()); }
public ActionResult Delete(int id, ContactViewModel contactViewModel) { Contact contactToBase = _contactRepository.FindById(id); _contactRepository.Delete(contactToBase); return(RedirectToAction("Index")); }
public void DeleteContactService(ContactDTO entity) { var contact = contactRepository.GetAll().Where(r => r.ContactId == entity.ContactId).FirstOrDefault(); contact.ContactMessage = entity.ContactMessage; contact.Sender = entity.Sender; contact.SendingDate = entity.SendingDate; contact.IsRead = entity.IsRead; contactRepository.Delete(contact); }
public void DeleteContact(Contact contact) { if (CurrentContacts.Contains(contact)) { CurrentContacts.Remove(contact); } _contactRepository.Delete(contact); StatusText = string.Format("Contact ‘{0}’ was deleted.", contact.LookupName); }
public void DeleteContact(Contact contact) { if (CurrentContacts.Contains(contact)) { CurrentContacts.Remove(contact); } _contactRepository.Delete(contact); StatusText = $"Contact '{contact.LookupName}' was deleted."; }
public void ICanDelete_Exposes_Delete_Entity() { var repo = new ContactRepository(new ConcurrentDictionary <int, Contact>()); var contact = new Contact { Name = "Test User" }; repo.Add(contact); repo.Delete(contact); }
public void ICanDelete_Exposes_Delete_By_Id() { var repo = new ContactRepository(); var contact = new Contact { Name = "Test User" }; repo.Add(contact); repo.Delete(1); }
public IHttpActionResult Delete(int id) { var user = ContactRepo.Get(id); if (user == null) { return(StatusCode(HttpStatusCode.NoContent)); } ContactRepo.Delete(id); return(StatusCode(HttpStatusCode.NoContent)); }
public void Delete_When_Called_Then_Call_Delete_AsExpected() { //Arrange _mockDatabase.Setup(x => x.Delete(It.IsAny <string>(), It.IsAny <SqlParameter[]>())).Verifiable(); //Act _sut.Delete(1); //Assert _mockDatabase.Verify(x => x.Delete(It.IsAny <string>(), It.IsAny <SqlParameter[]>()), Times.Once); }
public void Delete_Void_ReturnNull() { _contact.Id = _contactRepository.Create(_contact); var result = _contactRepository.Get(_contact.Id); AreEqualContacts(result, _contact); _contactRepository.Delete(_contact.Id); result = _contactRepository.Get(_contact.Id); Assert.IsNull(result); }
// DELETE api/values/5 public HttpResponseMessage Delete(int id) { var contact = _contactsRepository.Get().SingleOrDefault(y => y.Id == id); if (contact != null) { _contactsRepository.Delete(id); return(Request.CreateResponse(HttpStatusCode.Accepted)); } return(Request.CreateResponse(HttpStatusCode.NotFound)); }
public async Task <ActionResult <ContactRepresentation> > Delete(Guid id) { await CheckUserIdPermission(id); var entity = await _repository.Delete(id); if (entity == null) { return(NotFound()); } return(_mapper.Map <ContactRepresentation>(entity)); }
public void Given_ContactRepository_DeleteContact() { int deleteId = 1; ContactEntity entity = objRepo.GetById(deleteId); objRepo.Delete(entity); databaseContext.SaveChanges(); var result = objRepo.GetById(deleteId); Assert.AreEqual(result.IsActive, false); }
public void ICanDelete_Exposes_Delete_Multiple_Entities() { var repo = new ContactRepository(); var contact = new Contact { Name = "Test User" }; repo.Add(contact); repo.Add(contact); repo.Delete(new List <Contact> { contact, contact }); }
public void Delete_flags_correct_contact_as_inactive() { ContactRepository testContainer = GenerateSmallList(); testContainer.Delete(12); var contact = testContainer.Get(12); var contact2 = testContainer.Get(100); var contact3 = testContainer.Get(1); Assert.False(contact.isActiveRecord); Assert.True(contact2.isActiveRecord); Assert.True(contact3.isActiveRecord); }
public void Delete(int contactId) { using (IUnitOfWork unitOfWork = context.CreateUnitOfWork()) { Contact contact = contactRepo.GetById(contactId); if (!contactRepo.Delete(contact)) { throw new FailedOperationException("Failed to delete Contact.", contact); } unitOfWork.SaveChanges(); } }
public IHttpActionResult Delete(long id) { try { var repository = new ContactRepository(); repository.Delete(id); return(Content(HttpStatusCode.NoContent, string.Empty)); } catch (Exception ex) { return(this.BadRequest(ex.Message)); } }
public void _05_Delete_should_remove_entity() { var repository = new ContactRepository(); repository.Delete(id); // create a new repository for verification purposes var repository2 = new ContactRepository(); var deletedEntity = repository2.Find(id); // assert deletedEntity.Should().BeNull(); }
public IActionResult Delete(int personId) { if (personId < 1) { return(BadRequest("Invalid ID supplied")); } try { repository.Delete(personId); } catch (ArgumentException) { return(NotFound("Person not found")); } return(NoContent()); }
public ActionResult Delete(Contact contact) { try { _contact.Delete(contact); ViewBag.Message = "Contact deleted successfuly"; } catch (Exception ex) { Common.LogError(ModuleType.Delete, ex); } return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { Contact contact = contactRepository.GetByID(id); if (contact == null) { HttpNotFound(); } else { contactRepository.Delete(contact); return(RedirectToAction("ListContact", "Contact")); } return(View()); }
public void DeleteContact(Contact contact) { if (CurrentContacts.Contains(contact)) { CurrentContacts.Remove(contact); } _contactRepository.Delete(contact); string statusMessage = string.Format( "Contact <{0}> was deleted.", contact.LookupName ); UpdateStatusText(statusMessage); }
public void Delete(int id, Distributor distributor) { try { var contactToDelete = _contactRepository.GetById(id); if (contactToDelete.DistributorId != distributor.Id) { throw new Exception(string.Format("The contact with Id: {0} does not belong to this user.", distributor.Id)); } _contactRepository.Delete(contactToDelete); } catch (Exception exception) { throw new Exception(exception.Message); } }
public ActionResult DeleteConfirmed(int?id) { if (id != null) { ContactRepository contactRepo = new ContactRepository(); Contact contact = contactRepo.GetById(id.Value); if (contact != null && contact.UserID == AuthenticationService.LoggedUser.Id) { contact.Groups.Clear(); //one row took us like an hour to find!!! contactRepo.Delete(contact); return(RedirectToAction("Index")); } } return(HttpNotFound()); }
public void DeleteOnContactRepository() { //Arrange ContactNumberRepository contactNumberRepository = new ContactNumberRepository(_config); ContactRepository contactRepository = new ContactRepository(_config, contactNumberRepository); var contactToDelete = _contacts[4]; //Act contactRepository.Delete(contactToDelete.Id); Contact contact = contactRepository.Get(contactToDelete.Id); //Assert Assert.IsNull(contact); //Assert all contact Numbers for this contact have also been removed var contactNumbers = contactNumberRepository.GetAll().Where(cn => cn.ContactId == contactToDelete.Id).ToList(); Assert.AreEqual(0, contactNumbers.Count); }
public override bool OnContextItemSelected(IMenuItem item) { if (_position < 0) return false; switch (item.ItemId) { case Resource.Id.editSMS: using (var editSmsIntent = new Intent()) { editSmsIntent.PutExtra ("groupId", _smsGroups[_position].Id); editSmsIntent.SetClass (Activity, typeof(EditSmsGroupActivity)); StartActivity (editSmsIntent); } break; case Resource.Id.sendSMS: using (var sendMessage = new Intent()) { sendMessage.PutExtra ("groupId", _smsGroups[_position].Id); sendMessage.SetClass (Activity, typeof(SendMessageActivity)); StartActivity (sendMessage); } break; case Resource.Id.deleteSMS: new AlertDialog.Builder(Activity) .SetTitle ("Delete SMS Group") .SetMessage (string.Format ("Are you sure you want to delete the following group: {0}", _smsGroups[_position])) .SetPositiveButton ("Ok", (o, e) => { _progressDialog = new ProgressDialog(Activity); _progressDialog.SetTitle ("Delete SMS Group"); _progressDialog.SetMessage ("Please wait. Deleting SMS Group..."); _progressDialog.Show (); Task.Factory .StartNew(() => { var smsGroup = _smsGroups[_position]; //Delete all messages, group memebers, and then delete sms group var messageRepo = new SmsMessageRepository(); var messages = messageRepo.GetAllForGroup (smsGroup.Id); messages.ForEach (messageRepo.Delete); _contactRepo = new ContactRepository(Activity); var contacts = _contactRepo.GetMembersForSmsGroup(smsGroup.Id); contacts.ForEach (c => _contactRepo.Delete (c)); _smsGroupRepo.Delete (smsGroup); }) .ContinueWith(task => Activity.RunOnUiThread(() => { _smsGroups.RemoveAt (_position); ListAdapter = new GroupListAdapter(Activity, _smsGroups); ((BaseAdapter)ListAdapter).NotifyDataSetChanged (); _progressDialog.Dismiss (); })); }) .SetNegativeButton ("Cancel", (o, e) => { }) .Show (); break; } return base.OnContextItemSelected (item); }