public FlightPriceController()
 {
     _pathMapper             = new ServerPathMapper();
     _flightPricesRepository = new FlightCsvRepository("prices", _pathMapper);
     _currencyRateRepository = new CurrencyRateCsvRepository("currencies", _defaultCurrency, _pathMapper);
     _dataSanitizer          = new FlightDataSanitizer();
     _priceRangeCalculator   = new FlightDataCalculator(_dataSanitizer);
 }
 public FlightPriceController(IPathMapper pathmapper, IFlightPricesRepository flightPricesRepository, ICurrencyRateRepository currencyRateRepository,
                              IDataSanitizer <Flight> dataSanitizer, IPriceRangeCalculator <Flight> priceRangeCalculator)
 {
     _pathMapper             = pathmapper;
     _flightPricesRepository = flightPricesRepository;
     _currencyRateRepository = currencyRateRepository;
     _dataSanitizer          = dataSanitizer;
     _priceRangeCalculator   = priceRangeCalculator;
 }
예제 #3
0
 /// <summary>
 /// Tries to find currency rate for the specified currencies.
 /// </summary>
 /// <param name="repository">
 /// The currency rates repository.
 /// </param>
 /// <param name="currencyCode">
 /// The currency code.
 /// </param>
 /// <param name="targetCurrencyCode">
 /// The target currency code.
 /// </param>
 /// <returns>
 /// The currency rate or <b>null</b> if a rate not found.
 /// </returns>
 private static CurrencyRate GetCurrencyRate(
     ICurrencyRateRepository repository,
     int currencyCode,
     int targetCurrencyCode)
 {
     return(repository.FirstOrDefault(
                r => r.Currency.Code == currencyCode &&
                r.TargetCurrency.Code == targetCurrencyCode,
                r => r.Currency,
                r => r.TargetCurrency));
 }
예제 #4
0
 public CurrencyAppService(
     ICurrencyRepository currRepository,
     ICurrencyRateRepository currRateRepository,
     IBankApiService bankService,
     IUnitOfWork unitOfWork)
 {
     this.currRepository     = currRepository;
     this.currRateRepository = currRateRepository;
     this.bankService        = bankService;
     this.unitOfWork         = unitOfWork;
 }
예제 #5
0
        public MainWindowViewModel(
            ICurrencyCodeRepository currencyCodeRepository,
            ICurrencyRateRepository currencyRateRepository
            )
        {
            this.currencyCodeRepository = currencyCodeRepository;
            this.currencyRateRepository = currencyRateRepository;

            CurrencyCodes = new ObservableCollection <CurrencyCode>();
            CurrencyRates = new ObservableCollection <CurrencyRate>();
            SearchResults = new ObservableCollection <SearchResult>();

            LoadCurrencyCodesAsync();
            LoadCurrencyRatesAsync();
        }
예제 #6
0
 public CurrencyRateService(
     ILogger <ICurrencyRateRepository> logger,
     ICurrencyRateRepository currencyRateRepository,
     IApiCurrencyRateRequestModelValidator currencyRateModelValidator,
     IBOLCurrencyRateMapper bolcurrencyRateMapper,
     IDALCurrencyRateMapper dalcurrencyRateMapper,
     IBOLSalesOrderHeaderMapper bolSalesOrderHeaderMapper,
     IDALSalesOrderHeaderMapper dalSalesOrderHeaderMapper)
     : base(logger,
            currencyRateRepository,
            currencyRateModelValidator,
            bolcurrencyRateMapper,
            dalcurrencyRateMapper,
            bolSalesOrderHeaderMapper,
            dalSalesOrderHeaderMapper)
 {
 }
 public AbstractCurrencyRateService(
     ILogger logger,
     ICurrencyRateRepository currencyRateRepository,
     IApiCurrencyRateRequestModelValidator currencyRateModelValidator,
     IBOLCurrencyRateMapper bolCurrencyRateMapper,
     IDALCurrencyRateMapper dalCurrencyRateMapper,
     IBOLSalesOrderHeaderMapper bolSalesOrderHeaderMapper,
     IDALSalesOrderHeaderMapper dalSalesOrderHeaderMapper)
     : base()
 {
     this.currencyRateRepository     = currencyRateRepository;
     this.currencyRateModelValidator = currencyRateModelValidator;
     this.bolCurrencyRateMapper      = bolCurrencyRateMapper;
     this.dalCurrencyRateMapper      = dalCurrencyRateMapper;
     this.bolSalesOrderHeaderMapper  = bolSalesOrderHeaderMapper;
     this.dalSalesOrderHeaderMapper  = dalSalesOrderHeaderMapper;
     this.logger = logger;
 }
예제 #8
0
        /// <summary>
        /// Returns the album price in the specified currency and price level.
        /// </summary>
        /// <param name="albumPriceRepository">
        /// The repository.
        /// </param>
        /// <param name="currencyRatesRepository">
        /// The currency rates repository.
        /// </param>
        /// <param name="albumId">
        /// The album id.
        /// </param>
        /// <param name="currencyCode">
        /// The currency code.
        /// </param>
        /// <param name="priceLevelId">
        /// The price level id.
        /// </param>
        /// <returns>
        /// The album price in the specified currency and price level or <b>null</b>.
        /// </returns>
        internal static PriceViewModel GetAlbumPrice(
            IAlbumPriceRepository albumPriceRepository,
            ICurrencyRateRepository currencyRatesRepository,
            int albumId,
            int currencyCode,
            int priceLevelId)
        {
            var price = albumPriceRepository.FirstOrDefault(
                p => p.AlbumId == albumId &&
                p.PriceLevelId == priceLevelId &&
                p.Currency.Code == currencyCode,
                p => p.Album,
                p => p.Currency,
                p => p.PriceLevel);

            // if price is not exist for the specified currency then we'll try to find price in any other currency
            if (price == null)
            {
                price = albumPriceRepository.FirstOrDefault(
                    p => p.AlbumId == albumId &&
                    p.PriceLevelId == priceLevelId,
                    p => p.Currency);
                if (price != null)
                {
                    PriceViewModel targetPrice;
                    if (TryConvertToTargetPrice(
                            currencyRatesRepository,
                            price.Price,
                            price.Currency.Code,
                            currencyCode,
                            out targetPrice))
                    {
                        return(targetPrice);
                    }
                }
            }

            return(ModelsMapper.GetPriceViewModel(price));
        }
예제 #9
0
        /// <summary>
        /// Tries to convert price to price in the specified currency via a cross-cource.
        /// </summary>
        /// <param name="repository">
        /// The currency rates repository.
        /// </param>
        /// <param name="amount">
        /// The price amount.
        /// </param>
        /// <param name="currencyCode">
        /// The currency code.
        /// </param>
        /// <param name="targetCurrencyCode">
        /// The target currency code.
        /// </param>
        /// <param name="targetPrice">
        /// The convertion result.
        /// </param>
        internal static bool TryConvertToTargetPrice(
            ICurrencyRateRepository repository,
            decimal amount,
            int currencyCode,
            int targetCurrencyCode,
            out PriceViewModel targetPrice)
        {
            var rate = GetCurrencyRate(repository, currencyCode, targetCurrencyCode);

            if (rate != null)
            {
                targetPrice = new PriceViewModel
                {
                    // financial rounding to even
                    Amount   = Math.Round(rate.CrossCourse * amount, 2, MidpointRounding.ToEven),
                    Currency = ModelsMapper.GetCurrencyViewModel(rate.TargetCurrency)
                };
                return(true);
            }

            targetPrice = null;
            return(false);
        }
예제 #10
0
 public EveryDayCurrencyRatesJob(ICurrencyRateRepository currencyRateRepository, IPrivat24Factory privat24Factory, ILogger <EveryDayCurrencyRatesJob> log)
 {
     _logger = log;
     _currencyRateRepository = currencyRateRepository;
     _privat24Api            = privat24Factory.CreatePublicClient();
 }
예제 #11
0
 public CurrencyRateManager(ICurrencyRateRepository repo)
 {
     this._currencyRateRepository = repo;
 }
예제 #12
0
 public ApiCurrencyRateRequestModelValidator(ICurrencyRateRepository currencyRateRepository)
     : base(currencyRateRepository)
 {
 }
예제 #13
0
 public ConvertService(ICurrencyRateRepository currencyRateRepository)
 {
     this._currencyRateRepository = currencyRateRepository;
 }
 public AbstractApiCurrencyRateRequestModelValidator(ICurrencyRateRepository currencyRateRepository)
 {
     this.currencyRateRepository = currencyRateRepository;
 }
예제 #15
0
 public CurrencyManager(ICurrencyRepository currencyRepository, ICurrencyRateRepository currencyRateRepository)
 {
     _currencyRepository     = currencyRepository ?? throw new ArgumentNullException(nameof(currencyRepository));
     _currencyRateRepository = currencyRateRepository ?? throw new ArgumentNullException(nameof(currencyRateRepository));
 }
예제 #16
0
 public CurrencyRateController(ICurrencyRateRepository repository) => this.repository = repository;
예제 #17
0
 public ExchangeProvider(
     ICurrencyRateRepository cacheRepository,
     ILogger <ExchangeProvider> logger) =>
 (_cacheRepository, _logger) = (cacheRepository, logger);
예제 #18
0
		public CurrencyConvertor(ICurrencyRateRepository currencyRateRepository) {
			m_oCurrencyRateRepository = currencyRateRepository;
		} // constructor
 public CurrencyRateApplicationService(ILogger <CurrencyRateApplicationService> logger, ICurrencyRateRepository currencyRateRepository)
 {
     _logger = logger;
     _currencyRateRepository = currencyRateRepository;
 }
예제 #20
0
 public CurrencyRateService(ICurrencyRateRepository currencyRateRepository)
 {
     _currencyRateRepository = currencyRateRepository;
 }
예제 #21
0
 public CurrencyRateManager(ICurrencyRateRepository currencyRateRepository,
     ICurrencyRateCacher currencyRateCacher)
 {
     _currencyRateRepository = currencyRateRepository;
     _currencyRateCacher = currencyRateCacher;
 }