-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUsersController.cs
39 lines (33 loc) · 1.2 KB
/
UsersController.cs
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
using BugLab.API.Extensions;
using BugLab.Business.Helpers;
using BugLab.Business.Queries.Users;
using BugLab.Data.Extensions;
using BugLab.Shared.QueryParams;
using BugLab.Shared.Responses;
using Mapster;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading;
using System.Threading.Tasks;
namespace BugLab.API.Controllers
{
public class UsersController : BaseApiController
{
public UsersController(IMediator mediator) : base(mediator)
{
}
[HttpGet]
public async Task<ActionResult<PagedList<UserResponse>>> GetUsers([FromQuery] UserParams queryParams, CancellationToken cancellationToken)
{
var users = await _mediator.Send(queryParams.Adapt<GetUsersQuery>(), cancellationToken);
Response.AddPaginationHeader(users.PageNumber, users.PageSize, users.TotalPages, users.TotalItems);
return users;
}
[HttpGet("dashboard")]
public async Task<ActionResult<DashboardResponse>> GetDashboard(CancellationToken cancellationToken)
{
var dashboard = await _mediator.Send(new GetDashboardQuery(User.UserId()), cancellationToken);
return dashboard;
}
}
}