public bool UpdateContacts(IEnumerable <ContactsBo> contactList) { if (contactList == null) { throw new ValidationException(string.Format(BusinessRuleResource.Error_InstanceObject, nameof(contactList))); } return(_ruleProcessor.UpdateContacts(contactList)); }
public bool UpdateCustomer(CustomerBo customer) { using (var transaction = new TransactionScope()) { try { if (customer == null) { throw new EvaluateException(BusinessRuleResource.Error_CustomerObject); } if (customer.Id == 0) { throw new EvaluateException(string.Format(BusinessRuleResource.Error_InstanceId, nameof(customer))); } var customerUpdate = _customerRulesProcessor.UpdateCustomer(customer); if (!customerUpdate) { return(false); } var address = customer.CustomerAddress.Select(s => s.Address).ToArray(); var addressEmptyId = address.FirstOrDefault(s => s.Id == 0); if (addressEmptyId != null) { throw new EvaluateException(string.Format(BusinessRuleResource.Error_InstanceIdFor, nameof(address), addressEmptyId.Street)); } if (address.Any()) { _addressRuleProcessor.UpdateAddress(address); } var contacts = customer.CustomerContacts.Select(s => s.Contact).ToArray(); var emptyContact = contacts.FirstOrDefault(s => s.Id == 0); if (emptyContact != null) { throw new EvaluateException(string.Format(BusinessRuleResource.Error_InstanceIdFor, nameof(contacts), emptyContact.Contact)); } if (contacts.Any()) { _contactsRuleProcessor.UpdateContacts(contacts); } transaction.Complete(); } catch (Exception e) { transaction.Dispose(); throw e; } } return(true); }