public async Task <TipsOrderEntity> GetTipsOrder(string sku, string currency) { var transactions = await transactionsRepository.GetTransactionsBySku(sku).ConfigureAwait(false); if (!transactions.Any()) { return(null); } var rates = await ratesRepository.GetRates().ConfigureAwait(false); var transactionsResult = currencyService.Convert(currency, transactions, rates); var tipsTransactions = transactionsResult.Select(transactionEntity => new TipsTransactionEntity { Sku = transactionEntity.Sku, Amount = Math.Round(transactionEntity.Amount, 2), Currency = transactionEntity.Currency, Tip = Math.Round(transactionEntity.Amount * TIP_PORCENTAGE, 2) }).ToList(); var result = new TipsOrderEntity { Currency = Currencies.Euro, TotalTipAmount = Math.Round(transactionsResult.Sum(t => t.Amount) * TIP_PORCENTAGE, 2), Transactions = tipsTransactions }; return(result); }
public async Task <IList <RateEntity> > GetRates() { var rates = await ratesRepository.GetRates().ConfigureAwait(false); return(rates); }
public List <RateDto> GetRates(Guid recipeId) { return(_ratesRepository.GetRates(recipeId).Select(x => _mapper.Map <RateDto>(x)).ToList()); }