public bool Download(IStockDataRepo repo, string ticker, DateTime startDate, DateTime endDate)
        {
            //TODO: Validate ticker symbol before attempting download

            var start = new DateTimeOffset(startDate).ToUnixTimeSeconds();
            var end   = new DateTimeOffset(endDate).ToUnixTimeSeconds();  //DateTimeOffset.Now.ToUnixTimeSeconds();

            string yahooUrl = $"https://query1.finance.yahoo.com/v7/finance/download/{ticker}?period1={start}&period2={end}&interval=1d&events=history";

            using (var stocksStream = (new WebClient()).OpenRead(yahooUrl))
                using (var csvReader = new CsvReader(new StreamReader(stocksStream), CultureInfo.InvariantCulture))
                {
                    var fileRecords = csvReader.GetRecords <CsvStock>().ToList();

                    fileRecords.ForEach(s => s.Ticker = ticker);

                    var stockData = _mapper.Map <List <StockData> >(fileRecords);

                    repo.Add(stockData);
                    return(repo.SaveChanges());
                }
        }
 public StocksController(IStockDataRepo stockDataRepo, IMapper mapper)
 {
     _stockDataRepo = stockDataRepo;
     _mapper        = mapper;
 }