public async Task UpdateAsync(AssetType model, string username, string correlationId) { var brokerSettingsResponse = await _brokerSettingsApi.GetByIdAsync(_brokerId); if (brokerSettingsResponse.ErrorCode == BrokerSettingsErrorCodesContract.BrokerSettingsDoNotExist) { throw new BrokerSettingsDoNotExistException(); } await ValidateUnderlyingCategory(model.UnderlyingCategoryId); var regulationId = brokerSettingsResponse.BrokerSettings.RegulationId; await ValidateRegulatoryType(model.RegulatoryTypeId, regulationId); var existing = await _assetTypesRepository.GetByIdAsync(model.Id); if (existing == null) { throw new AssetTypeDoesNotExistException(); } var clientProfileSettings = await _clientProfileSettingsRepository.GetAllAsync(null, model.Id); foreach (var setting in clientProfileSettings) { var regulatorySettings = await _regulatorySettingsApi.GetRegulatorySettingsByIdsAsync( setting.RegulatoryProfileId, model.RegulatoryTypeId); ValidateRegulatoryConstraint(regulatorySettings, setting); } await _assetTypesRepository.UpdateAsync(model); await _auditService.TryAudit(correlationId, username, model.Id, AuditDataType.AssetType, model.ToJson(), existing.ToJson()); await _entityChangedSender.SendEntityEditedEvent <AssetType, AssetTypeContract, AssetTypeChangedEvent>( existing, model, username, correlationId); }