Ejemplo n.º 1
0
        public Stock GetRandomStock()
        {
            Random random       = new Random();
            int    stocksAmount = stockTableRepository.Count();

            if (stocksAmount == 0)
            {
                throw new NullReferenceException("There are no stocks to select from");
            }
            int   number = random.Next(1, stocksAmount);
            Stock stock  = stockTableRepository.GetElementAt(number);

            return(stock);
        }