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

                return(View(result));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <IActionResult> GroupingSearch(DateTime?minDate, DateTime?maxDate)
        {
            if (!minDate.HasValue)
            {
                minDate = new DateTime(DateTime.Now.Year, 1, 1);
            }

            if (!maxDate.HasValue)
            {
                minDate = DateTime.Now;
            }

            ViewData["minDate"] = minDate.Value.ToString("yyyy-MM-dd");
            ViewData["maxDate"] = maxDate.Value.ToString("yyyy-MM-dd");

            var result = await _salesRecordService.FindByDateGroupingAsync(minDate, maxDate);

            if (result == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Sales records not found in this date interval" }));
            }

            return(View(result));
        }
        public async Task <IActionResult> GroupingSearch(DateTime?minDate, DateTime?maxDate, SaleStatus returnedStatus)
        {
            if (minDate > maxDate)
            {
                return(RedirectToAction(nameof(Error), new { message = "Data Final deve que ser menor ou igual à inicial" }));
            }

            if (!minDate.HasValue)
            {
                minDate = new DateTime(DateTime.Now.Year, 1, 1);  // Se não for indicada data minima, inicializo a pesquisa com o dia 01/01/Ano atual.
            }

            if (!maxDate.HasValue)
            {
                maxDate = DateTime.Now;  // Se não for indicada data máxima, inicializo a pesquisa com a data atual.
            }

            ViewData["minDate"] = minDate.Value.ToString("yyyy-MM-dd");  // passar os valores de minDate e maxDate para a view
            ViewData["maxDate"] = maxDate.Value.ToString("yyyy-MM-dd");

            var result = await _salesRecordService.FindByDateGroupingAsync(minDate, maxDate, returnedStatus);

            return(View(result));
        }