示例#1
0
 public void UpdateCoinQuantities(IEnumerable <Coin> coins)
 {
     foreach (var coin in coins)
     {
         var coinDetail = coinRepository.Get(coin.CoinType);
         coinDetail.Quantity += coin.Quantity;
         coinRepository.Update(coinDetail);
     }
 }
        public async Task UpdateCoinSetting(CoinSetting coinSetting)
        {
            var coin = await _coinRepository.Get(coinSetting.Symbol);

            if (coin is null)
            {
                throw new Exception(Resource.FailedToUpdateCoinSetting);
            }

            _coinSetting = new CoinSetting(coin.Symbol);
        }
示例#3
0
        public async Task <CommandResult <CoinPriceDto> > Handle(GetCoinPriceCommand request,
                                                                 CancellationToken cancellationToken)
        {
            try
            {
                var coin = await _coinRepository.Get(request.Symbol);

                if (coin is null)
                {
                    throw new Exception(Resource.FailedToRetrieveCoin);
                }

                var coinPrice = await _coinService.GetCoinPrice(coin.Symbol);

                var coinPriceDto = _mapper.Map <CoinPriceDto>(coinPrice);
                return(new CommandResult <CoinPriceDto>(coinPriceDto));
            }
            catch (Exception e)
            {
                var failureReason = Resource.FailedToRetrieveCoinPrice;
                _logger.LogError(e, failureReason);
                return(new CommandResult <CoinPriceDto>(failureReason));
            }
        }
示例#4
0
        public async Task <IEnumerable <Coin> > Get()
        {
            var entities = await _coinRepo.Get();

            return(EntitiesToContracts(entities));
        }