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); }
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)); }
public async Task <RateDto> Create(RateDto dto) { var rate = RateMapper.Map(dto); await dbContext.Rates.AddAsync(rate); await dbContext.SaveChangesAsync(); return(RateDtoMapper.Map(rate)); }
public List<RateModel> BindFromEntities() { using (RepositoryHolder scope = new RepositoryHolder()) { RateMapper mapper = new RateMapper(); List<RateModel> result = mapper.EntityToModel( scope.RateRepository .Fetch() .ToList()); return result; } }
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(); }
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)); }
public ExchangeRateService(IConfiguration configuration, RateMapper rateMapper) { this.configuration = configuration; this.rateMapper = rateMapper; }