File size: 1,612 Bytes
3418204
e40d850
3418204
 
 
 
01be06d
3418204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecb51fa
3418204
 
 
 
 
 
ecb51fa
3418204
 
 
 
 
 
ecb51fa
3418204
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using TaskTrackingSystem.Shared;
using TaskTrackingSystem.Shared.Models.Dashboard;
using TaskTrackingSystem.WebApi.Infrastructure;

namespace TaskTrackingSystem.WebApi.Features.Dashboard
{
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class DashboardController : ControllerBase
    {
        private readonly DashboardService _dashboardService;

        public DashboardController(DashboardService dashboardService)
        {
            _dashboardService = dashboardService;
        }

        [HttpGet("summary")]
        public async Task<ActionResult<Result<DashboardSummaryDto>>> GetSummary()
        {
            var result = await _dashboardService.GetSummaryAsync(User.GetRoleId(), User.GetUserId());
            return StatusCode(result.StatusCode, result);
        }

        [HttpGet("tasks-overview")]
        public async Task<ActionResult<Result<IEnumerable<TaskStatusOverviewDto>>>> GetTasksOverview()
        {
            var result = await _dashboardService.GetTasksOverviewAsync(User.GetRoleId(), User.GetUserId());
            return StatusCode(result.StatusCode, result);
        }

        [HttpGet("project-progress")]
        public async Task<ActionResult<Result<IEnumerable<ProjectProgressDto>>>> GetProjectProgress()
        {
            var result = await _dashboardService.GetProjectProgressAsync(User.GetRoleId(), User.GetUserId());
            return StatusCode(result.StatusCode, result);
        }
    }
}