Пример #1
0
        public async Task <StatisticsResult> GetByPeriodAsync(DateTime startDate, DateTime endDate)
        {
            if (startDate >= endDate)
            {
                throw new InvalidOperationException($"{nameof(startDate)} must be earlier than {nameof(endDate)}");
            }

            var periodCountTask = _customerProfileRepository.GetByPeriodAsync(startDate, endDate);
            var totalCountTask  = _customerProfileRepository.GetTotalByDateAsync(endDate);
            await Task.WhenAll(periodCountTask, totalCountTask);

            return(new StatisticsResult
            {
                RegistrationsCount = periodCountTask.Result,
                TotalCount = totalCountTask.Result,
            });
        }