public void Create(IPortfolio portfolio, StockAction stockAction)
 {
     var stock = dbContext.Stocks.Where(s => s.Symbol == portfolio.StockSymbol).FirstOrDefault();
     bool purchased = stockAction == StockAction.Bought ? true : false;
     ITransactionLog entity = new Model.TransactionLog
     {
         Price = stock.LastPrice.Value,
         StockId = stock.ID,
         StockSymbol = stock.Symbol,
         Purchased = purchased,
         Quantity = portfolio.Quantity,
         TransactionDate = DateTime.Now
     };
     dbContext.TransactionLogs.Add(Mapper.Map<ITransactionLog, Data.TransactionLog>(entity));
     dbContext.SaveChanges();
 }
Example #2
0
        public void Create(IPortfolio portfolio, StockAction stockAction)
        {
            var             stock     = dbContext.Stocks.Where(s => s.Symbol == portfolio.StockSymbol).FirstOrDefault();
            bool            purchased = stockAction == StockAction.Bought ? true : false;
            ITransactionLog entity    = new Model.TransactionLog
            {
                Price           = stock.LastPrice.Value,
                StockId         = stock.ID,
                StockSymbol     = stock.Symbol,
                Purchased       = purchased,
                Quantity        = portfolio.Quantity,
                TransactionDate = DateTime.Now
            };

            dbContext.TransactionLogs.Add(Mapper.Map <ITransactionLog, Data.TransactionLog>(entity));
            dbContext.SaveChanges();
        }