public IEnumerable <GetAnalyticCovidCasesResult> Handle(GetAnalyticCovidCasesFilter filter) { var data = _csvContext.GetCsvData <CovidData>("Resources/input.csv"); var result = data .Select(x => new GetAnalyticCovidCasesResult { Cases = x.Cases, Date = x.Date, Deaths = x.Deaths, Uf = x.Uf }); if (!string.IsNullOrEmpty(filter?.month)) { result = result .Where(x => x.Date.ToString("yyyy-MM") == filter.month); } if (!string.IsNullOrEmpty(filter?.uf)) { result = result .Where(x => x.Uf == filter.uf); } return(result); }
public IActionResult Index([FromQuery] GetAnalyticCovidCasesFilter filter) { var data = _getAnalyticCovidQueryHandler.Handle(filter); return(Ok(data)); }