Пример #1
0
        public async Task UpdateAsync(SwiftCredentials swiftCredentials)
        {
            var existingSwiftCredentials = await _swiftCredentialsRepository.GetByIdAsync(swiftCredentials.Id);

            if (existingSwiftCredentials == null)
            {
                throw new SwiftCredentialsNotFoundException(swiftCredentials.Id);
            }

            await _swiftCredentialsRepository.UpdateAsync(swiftCredentials);

            await _clientSwiftCredentialsCache.ClearAsync("Swift credentials updated");

            await _log.WriteInfoAsync(nameof(SwiftCredentialsService), nameof(UpdateAsync),
                                      swiftCredentials.ToJson(), "Swift credentials updated");
        }
Пример #2
0
        public async Task AddAsync(SwiftCredentials swiftCredentials)
        {
            var existingSwiftCredentials = await _swiftCredentialsRepository
                                           .FindAsync(swiftCredentials.LegalEntityId, swiftCredentials.AssetId);

            if (existingSwiftCredentials.Count > 0)
            {
                throw new SwiftCredentialsAlreadyExistsException(swiftCredentials.LegalEntityId,
                                                                 swiftCredentials.AssetId);
            }

            var legalEntity = await _legalEntityRepository.GetByIdAsync(swiftCredentials.LegalEntityId);

            if (legalEntity == null)
            {
                throw new LegalEntityNotFoundException(swiftCredentials.LegalEntityId);
            }

            await _swiftCredentialsRepository.InsertAsync(swiftCredentials);

            await _log.WriteInfoAsync(nameof(SwiftCredentialsService), nameof(AddAsync),
                                      swiftCredentials.ToJson(), "Swift credentials added");
        }