Пример #1
0
        private async Task CreateAccount(CreateApplicationCommand request)
        {
            var accountData = await _accountsService.GetAccount(request.EncodedAccountId);

            await _levyTransferMatchingService.CreateAccount(new CreateAccountRequest(request.EmployerAccountId,
                                                                                      accountData.DasAccountName));
        }
        public async Task <CreatePledgeResult> Handle(CreatePledgeCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Creating Pledge for account {request.AccountId}");

            var account = await _levyTransferMatchingService.GetAccount(new GetAccountRequest(request.AccountId));

            if (account == null)
            {
                _logger.LogInformation($"Account {request.AccountId} does not exist - creating");
                await _levyTransferMatchingService.CreateAccount(new CreateAccountRequest(request.AccountId, request.DasAccountName));
            }

            var locationDataItems = new List <LocationDataItem>();

            foreach (var location in request.Locations)
            {
                var locationInformationResult = await _locationLookupService.GetLocationInformation(location, 0, 0);

                locationDataItems.Add(new LocationDataItem
                {
                    Name     = locationInformationResult.Name,
                    GeoPoint = locationInformationResult.GeoPoint
                });
            }

            var apiRequest = new CreatePledgeRequest(request.AccountId, new CreatePledgeRequest.CreatePledgeRequestData
            {
                AccountId       = request.AccountId,
                Amount          = request.Amount,
                IsNamePublic    = request.IsNamePublic,
                DasAccountName  = request.DasAccountName,
                Sectors         = request.Sectors,
                JobRoles        = request.JobRoles,
                Levels          = request.Levels,
                Locations       = locationDataItems,
                UserId          = request.UserId,
                UserDisplayName = request.UserDisplayName
            });

            var result = await _levyTransferMatchingService.CreatePledge(apiRequest);

            return(new CreatePledgeResult
            {
                PledgeId = result.Id,
            });
        }