public async Task <IActionResult> CreateAsync([FromBody] CreateOutgoingTransactionRequestModel model) { if (!ModelState.IsValid) { return(ValidationProblem(ModelState)); } var asset = model.Asset switch { "ETH" => VirtualAssetType.ETH, "BTC" => VirtualAssetType.BTC, _ => throw new NotSupportedException($"Asset {model.Asset} not recognized."), }; PlaceOfBirth placeOfBirth = null; if (model.OriginatorPlaceOfBirth != null) { var originatorPlaceOfBirthCountry = Country .List .Single(x => x.Value.TwoLetterCode == model.OriginatorPlaceOfBirth.CountryIso2Code) .Value; placeOfBirth = new PlaceOfBirth { Country = originatorPlaceOfBirthCountry, Date = model.OriginatorPlaceOfBirth.Date, Town = model.OriginatorPlaceOfBirth.Town }; } var originatorPostalAddressCountry = Country .List .Single(x => x.Value.TwoLetterCode == model.OriginatorPostalAddress.CountryIso2Code) .Value; var transaction = _transactionDataService.GenerateTransactionData( model.OriginatorFullName, model.OriginatorVaan, placeOfBirth, new PostalAddress { Country = originatorPostalAddressCountry, AddressLine = model.OriginatorPostalAddress.AddressLine, Building = model.OriginatorPostalAddress.Building, PostCode = model.OriginatorPostalAddress.PostCode, Street = model.OriginatorPostalAddress.Street, Town = model.OriginatorPostalAddress.Town }, model.BeneficiaryFullName, model.BeneficiaryVaan, asset, model.Amount, model.OriginatorNaturalPersonIds? .Select(x => new NaturalPersonId(x.Id, x.Type, Country.List[x.CountryIso2Code], x.NonStateIssuer)) .ToArray(), model.OriginatorJuridicalPersonIds? .Select(x => new JuridicalPersonId(x.Id, x.Type, Country.List[x.CountryIso2Code], x.NonStateIssuer)) .ToArray(), model.OriginatorBic, TransactionType.Outgoing); transaction = await _transactionsManager.RegisterOutgoingTransactionAsync( transaction, _transactionDataService.CreateVirtualAssetsAccountNumber(model.BeneficiaryVaan)); return(Ok(_mapper.Map <TransactionDetailsModel>(transaction))); }