Ejemplo n.º 1
0
        public void MapToViewModel_CorrectObject_FullObject()
        {
            // arrange
            var rateInput = new RateCalculation
            {
                Rate      = (decimal)2.51,
                RateValue = (decimal)2.5
            };
            var calculationInput = new CalculateRatesInputModel
            {
                SecondCurrency = "USD",
                FirstCurrency  = "LOT",
                Value          = (decimal)12.3
            };

            // act
            var result = RateMapper.MapToViewModel(rateInput, calculationInput);

            // assert
            Assert.Equal(rateInput.RateValue, result.RateValue);
            Assert.Equal(rateInput.Rate, result.Rate);
            Assert.Equal(calculationInput.FirstCurrency, result.FirtsCurrency);
            Assert.Equal(calculationInput.SecondCurrency, result.SecondCurrency);
            Assert.Equal(calculationInput.Value, result.Amount);
        }
Ejemplo n.º 2
0
        public async Task <RateDto> Update(RateDto dto)
        {
            var rate = await this.GetById(dto.Id);

            RateMapper.MapUpdate(rate, dto);
            await this.dbContext.SaveChangesAsync();

            return(RateDtoMapper.Map(rate));
        }
Ejemplo n.º 3
0
        public async Task <RateDto> Create(RateDto dto)
        {
            var rate = RateMapper.Map(dto);
            await dbContext.Rates.AddAsync(rate);

            await dbContext.SaveChangesAsync();

            return(RateDtoMapper.Map(rate));
        }
Ejemplo n.º 4
0
            public List<RateModel> BindFromEntities()
            {
                using (RepositoryHolder scope = new RepositoryHolder())
                {
                    RateMapper mapper = new RateMapper();

                    List<RateModel> result = mapper.EntityToModel(
                        scope.RateRepository
                        .Fetch()

                       .ToList());
                    return result;
                }

            }
Ejemplo n.º 5
0
 public Worker(string filePath)
 {
     this.filePath      = filePath;
     _parser            = new Parser();
     _analogMapper      = new AnalogMapper();
     _connectionMapper  = new ConnectionMapper();
     _legacyNameMapper  = new LegacyNameMapper();
     _messageMapper     = new MessageMapper();
     _multistateMapper  = new MultistateMapper();
     _rateMapper        = new RateMapper();
     _remConnJoinMapper = new RemConnJoinMapper();
     _remoteMapper      = new RemoteMapper();
     _stationMapper     = new StationMapper();
     _statusMapper      = new StatusMapper();
     _templateMapper    = new CGLTemplateMapper();
     _CGLMapper         = new CGLMapper();
 }
Ejemplo n.º 6
0
        public async Task <CalculateRatesResponseModel> CalculateRates(CalculateRatesInputModel calculateRatesInputModel)
        {
            var firstCurrency = await _dataLoadLogic.GetCurrency(calculateRatesInputModel.FirstCurrency);

            var secondCurrency = await _dataLoadLogic.GetCurrency(calculateRatesInputModel.SecondCurrency);

            if (firstCurrency == null || secondCurrency == null)
            {
                throw new CurrencyNotFoundException();
            }

            var rateCalculation = new RateCalculation()
            {
                RateValue = CaclulateRateValue(firstCurrency.Value, secondCurrency.Value, calculateRatesInputModel.Value),
                Rate      = CaclulateRate(firstCurrency.Value, secondCurrency.Value)
            };

            return(RateMapper.MapToViewModel(rateCalculation, calculateRatesInputModel));
        }
Ejemplo n.º 7
0
 public ExchangeRateService(IConfiguration configuration, RateMapper rateMapper)
 {
     this.configuration = configuration;
     this.rateMapper    = rateMapper;
 }