Esempio n. 1
0
 public void AddFutureTransfers(
     List <TransferCreateOptions> transferOptions,
     IStripeCharge stripeChargeParameters,
     string chargeId,
     string currencyCode,
     Channels channels)
 {
     foreach (TransferCreateOptions transferCreateOption in transferOptions)
     {
         var dict            = transferCreateOption.ExtraParams;
         var transferService = new TransferService();
         //remove trasnfer service here and setup API call via schedular in future.
         //this is not done in inject stripeconnect class since i need to also store chargeIDs
         var transactionStripeConnectTransfersRepository = new TransactionStripeConnectTransfers();
         transactionStripeConnectTransfersRepository.Amount     = transferCreateOption.Amount.Value;
         transactionStripeConnectTransfersRepository.CreatedBy  = (Guid)dict["CreatedBy"];
         transactionStripeConnectTransfersRepository.CreatedUtc = DateTime.UtcNow;
         transactionStripeConnectTransfersRepository.CurrencyId = _currencyTypeRepository.GetByCurrencyCode(currencyCode).Id;
         transactionStripeConnectTransfersRepository.SourceTransactionChargeId = chargeId;
         transactionStripeConnectTransfersRepository.StripeConnectedAccount    = transferCreateOption.Destination;
         transactionStripeConnectTransfersRepository.TransactionId             = stripeChargeParameters.TransactionId;
         transactionStripeConnectTransfersRepository.TransferDateProposed      = (DateTime)dict["EndDateTime"];
         transactionStripeConnectTransfersRepository.ChannelId = channels;
         _transactionStripeConnectTransfersRepository.Save(transactionStripeConnectTransfersRepository);
     }
 }
Esempio n. 2
0
        public async Task <SaveLocationReturnValues> SaveCityStateCountry(ChauffeurRoute routeDetail, ValueRetailVillage village)
        {
            var locationData = await _googleMapApi.GetLatLongFromAddress(routeDetail.LocationHeader);

            try
            {
                if (!locationData.Success)
                {
                    throw new ArgumentNullException(locationData.Result.CityName, "Failed to get Location Data");
                }

                var countryCodeAndCurrency = await _countryAlphaCode.GetCountryCodeByName(locationData.Result.CountryName);

                var country = _countryRepository.GetByName(locationData.Result.CountryName);
                if (country == null)
                {
                    country = _countryRepository.Save(new Country
                    {
                        Name              = locationData.Result.CountryName,
                        IsoAlphaTwoCode   = countryCodeAndCurrency.Result.IsoAlphaTwoCode.ToUpper(),
                        IsoAlphaThreeCode = countryCodeAndCurrency.Result.IsoAlphaThreeCode.ToUpper(),
                        IsEnabled         = true,
                    });
                }

                var state = _stateRepository.GetByNameAndCountryId(locationData.Result.StateName, country.Id);
                if (state == null)
                {
                    state = _stateRepository.Save(new State
                    {
                        Name      = locationData.Result.StateName,
                        CountryId = country.Id,
                        IsEnabled = true,
                    });
                }

                var city = _cityRepository.GetByNameAndStateId(locationData.Result.CityName, state.Id);
                if (city == null)
                {
                    city = _cityRepository.Save(new City
                    {
                        Name      = locationData.Result.CityName,
                        StateId   = state.Id,
                        IsEnabled = true,
                    });
                }

                var currencyType = _currencyTypeRepository.GetByCurrencyCode(village.CurrencyCode.ToUpper());
                if (currencyType == null)
                {
                    currencyType = _currencyTypeRepository.Save(new CurrencyType
                    {
                        Code       = village.CurrencyCode.ToUpper(),
                        Name       = village.CurrencyCode.ToUpper(),
                        CountryId  = country.Id,
                        ModifiedBy = Guid.NewGuid(),
                        IsEnabled  = true
                    });
                }
                var values = new SaveLocationReturnValues
                {
                    cityId     = city.Id,
                    currencyId = currencyType.Id,
                    lat        = locationData.Result.lat,
                    lng        = locationData.Result.lng
                };

                return(values);
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, ex);
                return(new SaveLocationReturnValues());
            }
        }