/// <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(AddressDto t) { var dbEntity = typeAdapter.ConvertDtoToEntities(t); entiesrepository.Attach(dbEntity); entiesrepository.Delete(dbEntity); entiesrepository.Save(); return(true); }
internal void UpdateAddress(int id, string street1, string street2, string city, string state, string country, string postal, string type, int contactId) { var aRep = new AddressRepository(_uow); var addresses = GetCustomerAddresses(contactId); var origAddress = addresses.First(a => a.addressID == id); aRep.Attach(origAddress); if (origAddress == null) { return; } //update only changed fields if (street1 != origAddress.Street1) { origAddress.Street1 = street1; } if (origAddress.Street2 != street2) { origAddress.Street2 = street2; } if (country != origAddress.CountryRegion) { origAddress.CountryRegion = country; } if (state != origAddress.StateProvince) { origAddress.StateProvince = state; } _uow.Save(); }