Example #1
0
 public ForeignAmountViewModelFactory(
     ILoggerFactory loggerFactory,
     ICurrencyExchangeService currencyExchangeService)
 {
     m_loggerFactory           = loggerFactory;
     m_currencyExchangeService = currencyExchangeService;
 }
Example #2
0
        public ForeignAmountViewModel(
            ILoggerFactory loggerFactory,
            ICurrencyExchangeService currencyExchangeService,
            decimal nativeAmount,
            string nativeCurrencyCode,
            string foreignCurrencyCode)
        {
            m_logger = loggerFactory.CreateLogger <ForeignAmountViewModel>();
            m_currencyExchangeService = currencyExchangeService;

            m_foreignCurrencyCode = foreignCurrencyCode;
            m_nativeCurrencyCode  = nativeCurrencyCode;
            m_foreignToNativeRate = m_currencyExchangeService.GetExchangeRate(
                m_foreignCurrencyCode,
                m_nativeCurrencyCode,
                DateTime.Now
                );
            m_nativeAmount  = nativeAmount;
            m_foreignAmount = Math.Round((m_nativeAmount / m_foreignToNativeRate), 2);
        }
Example #3
0
 public CsShipmentSurchargeService(IContextBase <CsShipmentSurcharge> repository, IMapper mapper, IStringLocalizer <LanguageSub> localizer,
                                   IContextBase <CsTransactionDetail> tranDetailRepo,
                                   IContextBase <CatPartner> partnerRepo,
                                   IContextBase <OpsTransaction> opsTransRepo,
                                   IContextBase <CatCurrencyExchange> currentExchangeRateRepo,
                                   IContextBase <CatCharge> catChargeRepo,
                                   IContextBase <CsTransaction> csTransactionRepo,
                                   ICurrentUser currUser,
                                   ICsTransactionDetailService transDetailService,
                                   ICurrencyExchangeService currencyExchange
                                   ) : base(repository, mapper)
 {
     stringLocalizer               = localizer;
     tranDetailRepository          = tranDetailRepo;
     partnerRepository             = partnerRepo;
     opsTransRepository            = opsTransRepo;
     currentExchangeRateRepository = currentExchangeRateRepo;
     csTransactionRepository       = csTransactionRepo;
     currentUser              = currUser;
     catChargeRepository      = catChargeRepo;
     transactionDetailService = transDetailService;
     currencyExchangeService  = currencyExchange;
 }
 public ExchangeRatesController(ICurrencyExchangeService currencyExchangeService, IMemoryCache memoryCache)
 {
     _currencyExchangeService = currencyExchangeService;
     _cache = memoryCache;
 }
 public CurrencyExchangeController(IRatesService ratesService, ICurrencyExchangeService currencyExchangeService)
 {
     RatesService            = ratesService;
     CurrencyExchangeService = currencyExchangeService;
 }
Example #6
0
        /// <summary>
        /// Gets a product report with local country information.
        /// </summary>
        /// <param name="countryCurrencyService">Service to get country info.</param>
        /// <param name="currencyExchangeService">Service to get currency info.</param>
        /// <returns>Returns <see cref="ProductReport{ProductLocalPrice}"/>.</returns>
        public async Task <ProductReport <ProductLocalPrice> > GetCurrentProductsWithLocalCurrencyReport(ICountryCurrencyService countryCurrencyService, ICurrencyExchangeService currencyExchangeService)
        {
            if (countryCurrencyService is null)
            {
                throw new ArgumentNullException(nameof(countryCurrencyService));
            }

            if (currencyExchangeService is null)
            {
                throw new ArgumentNullException(nameof(currencyExchangeService));
            }

            var query = (DataServiceQuery <ProductLocalPrice>) this.entities.Products.
                        Where(p => p.UnitPrice != null).
                        OrderBy(p => p.ProductName).
                        Select(p => new ProductLocalPrice
            {
                Name    = p.ProductName,
                Price   = p.UnitPrice ?? 0,
                Country = p.Supplier.Country,
            });

            var localPrices = await Task <ProductLocalPrice[]> .Factory.FromAsync(query.BeginExecute(null, null), (ar) =>
            {
                return(query.EndExecute(ar).ToArray());
            });

            for (int i = 0; i < localPrices.Length; i++)
            {
                var countryInfo = await countryCurrencyService.GetLocalCurrencyByCountry(localPrices[i].Country);

                var currencyExchange = await currencyExchangeService.GetCurrencyExchangeRate("USD", countryInfo.CurrencyCode);

                localPrices[i].Country        = countryInfo.CountryName;
                localPrices[i].LocalPrice     = localPrices[i].Price * currencyExchange;
                localPrices[i].CurrencySymbol = countryInfo.CurrencySymbol;
            }

            return(new ProductReport <ProductLocalPrice>(localPrices));
        }
        /// <inheritdoc/>
        public async Task <ProductReport <ProductLocalPrice> > GetCurrentProductsWithLocalCurrencyReport(ICountryCurrencyService countryCurrencyService, ICurrencyExchangeService currencyExchangeService)
        {
            var products = await this.GetAllProducts();

            var suppliers = await this.GetAllSupplies();

            var productsWithLocalPrices = products.Select(p => new ProductLocalPrice
            {
                Name    = p.ProductName,
                Price   = p.UnitPrice ?? 0,
                Country = suppliers.Where(s => s.SupplierID == p.SupplierID).Select(s => s.Country).First(),
            }).ToArray();

            for (int i = 0; i < productsWithLocalPrices.Length; i++)
            {
                var countryInfo = await countryCurrencyService.GetLocalCurrencyByCountry(productsWithLocalPrices[i].Country);

                var currencyExchangeRate = await currencyExchangeService.GetCurrencyExchangeRate("USD", countryInfo.CurrencyCode);

                productsWithLocalPrices[i].Country        = countryInfo.CountryName;
                productsWithLocalPrices[i].CurrencySymbol = countryInfo.CurrencySymbol;
                productsWithLocalPrices[i].LocalPrice     = productsWithLocalPrices[i].Price * currencyExchangeRate;
            }

            return(new ProductReport <ProductLocalPrice>(productsWithLocalPrices));
        }
 public TransactionsController(ICurrencyExchangeService currencyExchangeService)
 {
     CurrencyExchangeService = currencyExchangeService;
 }
 public IndexModel(ICurrencyExchangeService exchangeService)
 {
     this.exchangeService = exchangeService;
 }
Example #10
0
 public Task <ProductReport <ProductLocalPrice> > GetCurrentProductsWithLocalCurrencyReport(ICountryCurrencyService countryCurrencyService, ICurrencyExchangeService currencyExchangeService)
 {
     throw new NotImplementedException();
 }
Example #11
0
        public async Task<ProductReport<ProductLocalPrice>> GetCurrentProductsWithLocalCurrencyReport(ICountryCurrencyService countryCurrencyService, ICurrencyExchangeService currencyExchangeService)
        {
            var query = (DataServiceQuery<ProductLocalPrice>)(
            from p in this.entities.Products
            where !p.Discontinued
            select new ProductLocalPrice
            {
                Name = p.ProductName,
                Price = p.UnitPrice ?? 0,
                Country = p.Supplier.Country,
                LocalPrice = currencyExchangeService.GetCurrencyExchangeRate("USD", countryCurrencyService.GetLocalCurrencyByCountry(p.Supplier.Country).Result.CurrencyCode).Result * (p.UnitPrice ?? 0),
                CurrencySymbol = countryCurrencyService.GetLocalCurrencyByCountry(p.Supplier.Country).Result.CurrencySymbol,
            }) ;

            return await this.GetAllProductReport(query).ConfigureAwait(false);
        }
Example #12
0
 public AutoPriceCalculationService(IRepository <Product> productRepository, ICurrencyExchangeService currencyExchangeService)
 {
     _productRepository       = productRepository;
     _currencyExchangeService = currencyExchangeService;
 }
 public CurrencyExchangeCalculatorController(ILogger <CurrencyExchangeCalculatorController> logger, ICurrencyExchangeService service)
 {
     _logger  = logger;
     _service = service;
 }
 public HomeController(ICurrencyExchangeService apiService)
 {
     _apiService = apiService;
 }
Example #15
0
 public CurrentProductLocalPriceReport(IProductReportService productReportService, ICurrencyExchangeService currencyExchangeService, ICountryCurrencyService countryCurrencyService)
 {
     this.productReportService    = productReportService ?? throw new ArgumentNullException(nameof(productReportService));
     this.currencyExchangeService = currencyExchangeService ?? throw new ArgumentNullException(nameof(currencyExchangeService));
     this.countryCurrencyService  = countryCurrencyService ?? throw new ArgumentNullException(nameof(countryCurrencyService));
 }
Example #16
0
 public CurrencyExchangeController(ICurrencyExchangeService currencyExchangeService)
 {
     _currencyExchangeService = currencyExchangeService;
 }
Example #17
0
 public RealBrCurrencyService(DollarCurrencyService dollarExchangeService)
 {
     _currencyExchangeService = dollarExchangeService;
 }