public static TradeHistory MapToOverViewViewModel(this CryptoTradeHistory cryptoTradeHistory)
 {
     return(new TradeHistory
     {
         CryptoTicker = cryptoTradeHistory.CryptoTicker.Ticker,
         CryptoTickerId = cryptoTradeHistory.CryptoTickerId,
         CurrencySymbol = cryptoTradeHistory.CurrencySymbol.Symbol,
         CurrencySymbolId = cryptoTradeHistory.CurrencySymbolId,
         Id = cryptoTradeHistory.Id,
         TradeSize = cryptoTradeHistory.TradeSize,
         TradeTimeStamp = cryptoTradeHistory.TradeTimeStamp,
         TradeValue = cryptoTradeHistory.TradeValue
     });
 }
Exemplo n.º 2
0
        private void MapCoinbaseRecordToDbRecord(CoinbaseRecord coinbaseRecord)
        {
            int crypto   = this.cryptoTickers.Single(t => string.Equals(t.Ticker, coinbaseRecord.SizeUnit, StringComparison.OrdinalIgnoreCase)).Id;
            int currency = currencySymbols.Single(t => string.Equals(t.Symbol, coinbaseRecord.PriceFeeTotalUnit, StringComparison.OrdinalIgnoreCase)).Id;

            CryptoTradeHistory cryptoTradeHistory = new CryptoTradeHistory
            {
                CryptoTickerId   = crypto,
                CurrencySymbolId = currency,
                TradeValue       = coinbaseRecord.Total * -1,
                TradeSize        = coinbaseRecord.Size,
                TradeTimeStamp   = coinbaseRecord.CreatedAt,
                UserIdentityId   = 1 // for testing purpose no user contedxt in this app
            };

            this.cryptoTradeHistoryRepository.Create(cryptoTradeHistory);
        }
Exemplo n.º 3
0
        public void Update(TradeHistory tradeHistory)
        {
            CryptoTradeHistory tradeHistoryRecord = this.userIdentityRepository.FindByCondition(u => u.Login == this.GetUserIdentity())
                                                    .SelectMany(a => a.CryptoTradesHistory)
                                                    .Include(s => s.CurrencySymbol)
                                                    .Include(s => s.CryptoTicker)
                                                    .Single(s => s.Id == tradeHistory.Id);

            if (tradeHistoryRecord == null)
            {
                throw new Exception();
            }

            tradeHistoryRecord.CryptoTickerId   = tradeHistory.CryptoTickerId;
            tradeHistoryRecord.CurrencySymbolId = tradeHistory.CurrencySymbolId;
            tradeHistoryRecord.TradeSize        = tradeHistory.TradeSize;
            tradeHistoryRecord.TradeTimeStamp   = tradeHistory.TradeTimeStamp;
            tradeHistoryRecord.TradeValue       = tradeHistory.TradeValue;

            this.cryptoTradeHistoryRepository.Update(tradeHistoryRecord);
        }