Beispiel #1
0
        public async Task <IEnumerable <FundDTO> > GetAllFunds()
        {
            var funds    = _cryptoContext.Funds;
            var dtos     = _mapper.Map <IEnumerable <FundDTO> >(funds);
            var fundDtos = dtos as FundDTO[] ?? dtos.ToArray();

            foreach (var fundDto in fundDtos)
            {
                var exchange = await _cryptoContext.Exchanges.FindAsync(fundDto.ExchangeId);

                fundDto.ExchangeName    = exchange.ExchangeId.ToString();
                fundDto.CurrentFiatRate = await _marketData.GetCurrentRate("CHF", fundDto.Currency);

                fundDto.WorthFiat = fundDto.Amount * fundDto.CurrentFiatRate;
                fundDto.CoinMeta  = await _marketData.GetCoinInfo(fundDto.Currency);
            }
            return(fundDtos);
        }