Пример #1
0
        public async Task InsertAsync(ISwiftCredentials swiftCredentials)
        {
            var entity = new SwiftCredentialsEntity
            {
                PartitionKey = GetPartitionKey(swiftCredentials.RegulatorId),
                RowKey       = GetRowKey(swiftCredentials.AssetId)
            };

            Mapper.Map(swiftCredentials, entity);

            try
            {
                await _storage.InsertAsync(entity);
            }
            catch (StorageException exception)
            {
                if (exception.RequestInformation != null &&
                    exception.RequestInformation.HttpStatusCode == 409 &&
                    exception.RequestInformation.ExtendedErrorInformation.ErrorCode == TableErrorCodeStrings.EntityAlreadyExists)
                {
                    throw new SwiftCredentialsAlreadyExistsException("Already exists", exception)
                          {
                              RegulationId = swiftCredentials.RegulatorId,
                              AssetId      = swiftCredentials.AssetId
                          };
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> GetAsync(string regulationId, string assetId)
        {
            ISwiftCredentials swiftCredentials = await _swiftCredentialsService.GetAsync(regulationId, assetId);

            var model = Mapper.Map <SwiftCredentialsModel>(swiftCredentials);

            return(Ok(model));
        }
        public async Task UpdateAsync(ISwiftCredentials swiftCredentials)
        {
            bool updated = await _swiftCredentialsRepository.UpdateAsync(swiftCredentials);

            if (!updated)
            {
                throw new SwiftCredentialsNotFoundException("Swift credentials not found")
                      {
                          RegulatorId = swiftCredentials.RegulatorId,
                          AssetId     = swiftCredentials.AssetId
                      };
            }
        }
Пример #4
0
        public async Task <bool> UpdateAsync(ISwiftCredentials swiftCredentials)
        {
            SwiftCredentialsEntity swiftCredentialsEntity = await _storage.MergeAsync(
                GetPartitionKey(swiftCredentials.RegulatorId),
                GetRowKey(swiftCredentials.AssetId),
                entity =>
            {
                Mapper.Map(swiftCredentials, entity);
                return(entity);
            });

            return(swiftCredentialsEntity != null);
        }
        public async Task <IActionResult> GetAsync(string clientId, string regulationId, string assetId)
        {
            ISwiftCredentials swiftCredentials = await _swiftCredentialsService.GetAsync(regulationId, assetId);

            var model = Mapper.Map <SwiftCredentialsModel>(swiftCredentials);

            model.PurposeOfPayment =
                await _purposeOfPaymentBuilder.Build(
                    model.PurposeOfPayment,
                    clientId,
                    assetId);

            return(Ok(model));
        }
        public async Task <ISwiftCredentials> GetAsync(string regulationId, string assetId)
        {
            ISwiftCredentials swiftCredentials = await _swiftCredentialsRepository.GetAsync(regulationId, assetId);

            if (swiftCredentials == null)
            {
                throw new SwiftCredentialsNotFoundException("Swift credentials not found")
                      {
                          RegulatorId = regulationId,
                          AssetId     = assetId
                      };
            }

            return(swiftCredentials);
        }
Пример #7
0
 public static SwiftCredentialsEntity Create(ISwiftCredentials credentials)
 {
     return(new SwiftCredentialsEntity
     {
         PartitionKey = GeneratePartitionKey(credentials.RegulatorId),
         RowKey = GenerateRowKey(credentials.AssetId),
         RegulatorId = credentials.RegulatorId,
         AssetId = credentials.AssetId,
         AccountName = credentials.AccountName,
         AccountNumber = credentials.AccountNumber,
         BIC = credentials.BIC,
         BankAddress = credentials.BankAddress,
         CompanyAddress = credentials.CompanyAddress,
         PurposeOfPayment = credentials.PurposeOfPayment
     });
 }
Пример #8
0
        private async Task <ISwiftCredentials> BuildCredentials(string assetId, ISwiftCredentials sourceCredentials,
                                                                IPersonalData personalData)
        {
            if (sourceCredentials == null)
            {
                return(null);
            }

            var asset = await _assetsService.TryGetAssetAsync(assetId);

            var assetTitle = asset?.DisplayId ?? assetId;

            var clientIdentity = personalData != null?personalData.Email.Replace("@", ".") : "{1}";

            var purposeOfPayment = string.Format(sourceCredentials.PurposeOfPayment, assetTitle, clientIdentity);

            if (!purposeOfPayment.Contains(assetId) && !purposeOfPayment.Contains(assetTitle))
            {
                purposeOfPayment += assetTitle;
            }

            if (!purposeOfPayment.Contains(clientIdentity))
            {
                purposeOfPayment += clientIdentity;
            }

            return(new Core.Domain.SwiftCredentials.SwiftCredentials
            {
                AssetId = assetId,
                RegulatorId = sourceCredentials.RegulatorId,
                BIC = sourceCredentials.BIC,
                PurposeOfPayment = purposeOfPayment,
                CompanyAddress = sourceCredentials.CompanyAddress,
                AccountNumber = sourceCredentials.AccountNumber,
                BankAddress = sourceCredentials.BankAddress,
                AccountName = sourceCredentials.AccountName
            });
        }
 public async Task InsertAsync(ISwiftCredentials swiftCredentials)
 {
     await _swiftCredentialsRepository.InsertAsync(swiftCredentials);
 }