public async Task <IActionResult> GroupingSearch(DateTime?minDate, DateTime?maxDate) { if (!minDate.HasValue) { //minDate = new DateTime(DateTime.Now.Year, 1, 1); minDate = _salesRecordService.FindEarliestDate(); } if (!maxDate.HasValue) { //maxDate = DateTime.Now; maxDate = _salesRecordService.FindOldestDate(); } ViewData["minDate"] = minDate.Value.ToString("yyyy-MM-dd"); ViewData["maxDate"] = maxDate.Value.ToString("yyyy-MM-dd"); var result = await _salesRecordService.FindByDateGroupingAsync(minDate, maxDate); return(View(result)); }