Пример #1
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");
        }
Пример #2
0
 public Task <LegalEntity> GetByIdAsync(string legalEntityId)
 {
     return(_legalEntityRepository.GetByIdAsync(legalEntityId));
 }