public void SetAddress(Address address) { if (address == null) { throw new ArgumentNullException(nameof(address)); } var existingAddress = CompanyAddresses.FirstOrDefault(a => a.AddressType.AddressTypeCode == address.AddressType.AddressTypeCode); if (existingAddress != null) { CompanyAddresses.Remove(existingAddress); } CompanyAddresses.Add(address); }
private void SetAddress(AddressViewModel addressData) { if (addressData == null) { throw new ArgumentNullException(nameof(addressData)); } var existingAddress = CompanyAddresses.FirstOrDefault(a => a.AddressType.AddressTypeCode == addressData.AddressType.AddressTypeCode); if (existingAddress != null) { CompanyAddresses.Remove(existingAddress); } CompanyAddresses.Add(addressData); }