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); }
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)); } }
public async Task <IEnumerable <Coin> > Get() { var entities = await _coinRepo.Get(); return(EntitiesToContracts(entities)); }