Example #1
0
        public async Task <IActionResult> AgentsActivities(AgentsActivitiesViewModel viewModel)
        {
            DateTime fromDate;
            DateTime toDate;

            if (viewModel.FromDate != null && viewModel.ToDate != null)
            {
                // Make fromDate's = viewModel.FromDate with time of 00:00.
                fromDate = viewModel.FromDate.Value
                           .AddMilliseconds(-viewModel.FromDate.Value.TimeOfDay.TotalMilliseconds);

                // Make toDate's = viewModel.ToDate with time of 23:59.
                toDate = viewModel.ToDate.Value
                         .AddDays(1)
                         .AddMilliseconds(-viewModel.ToDate.Value.TimeOfDay.TotalMilliseconds - 1);
            }
            else
            {
                fromDate = CalculateFromAndToDatesByTimeFrameEnum.CalculateFromDate(viewModel.TimeFrame);
                toDate   = CalculateFromAndToDatesByTimeFrameEnum.CalculateToDate(viewModel.TimeFrame);
            }

            viewModel.SelectedAgents = await this.usersStatisticsService
                                       .GetAgentsActivitiesReportsAsync(viewModel.UserId, fromDate, toDate);

            viewModel.AllAgents = await this.usersService.GetAllAgentsIdAndFullNameAsync();

            return(View(viewModel));
        }
        public async Task <IActionResult> OnGetAsync(TimeFrameEnum timeFrame)
        {
            string userId = userManager.GetUserId(User);

            var fromDate = CalculateFromAndToDatesByTimeFrameEnum.CalculateFromDate(timeFrame);
            var toDate   = CalculateFromAndToDatesByTimeFrameEnum.CalculateToDate(timeFrame);

            OutputModel = await agentsStatisticsAndReportsService.GetAgentsStatisticsAsync(userId, fromDate, toDate);

            OutputModel.TimeFrameOutput = timeFrame;

            return(Page());
        }