public IEnumerable <StockPriceDto> FetchComapnyStockPrices(StockPriceRequestDto spq) { var stock_prices = repository.GetMultiple (spq.CompanyId, spq.StockExchangeId, Convert.ToDateTime(spq.From), Convert.ToDateTime(spq.To)); var stock_price_dtos = new List <StockPriceDto>(); DateTime till_date = Convert.ToDateTime(spq.From); foreach (StockPrice sp in stock_prices) { if (sp.DateTime >= till_date) { stock_price_dtos.Add( new StockPriceDto { Price = sp.Price, Date = sp.DateTime.ToShortDateString(), Time = sp.DateTime.ToShortTimeString(), CompanyId = sp.CompanyId, StockExchangeId = sp.StockExchangeId }); till_date += GetPeriod(spq.Periodicity); } } return(stock_price_dtos); }
public IActionResult GetComapnyStockPrices(StockPriceRequestDto spq) { if (ModelState.IsValid) { return(Ok(sp_service.FetchComapnyStockPrices(spq))); } return(BadRequest(ModelState)); }