Ejemplo n.º 1
0
        public async Task <IActionResult> TodayStatistics(int projectId)
        {
            var project = await _projects.GetProjectAsync(projectId);

            if (project == null)
            {
                return(NotFound());
            }

            if (!await _authorizationService.AuthorizeAsync(User, project, "IsOwner"))
            {
                return(NotFound());
            }

            var now      = _timers.GetNowTime(project);
            var timers   = _timers.GetTimersInInterval(project, now.Date, null);
            var duration = _timers.GetDuration(timers);

            return(new OkObjectResult(new {
                timers = timers,
                duration = duration,
                isRunning = await _timers.GetOpenedTimerAsync(project) != null,
                progress = await _norms.GetProgressAsync(project, now.Date)
            }));
        }