Files
myoffice/MyOffice.Web/Controllers/DashboardController.cs
T
2023-08-03 08:58:53 +03:00

52 lines
1.2 KiB
C#

namespace MyOffice.Web.Controllers;
using Core.Extensions;
using Infrastructure.Attributes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Services.Dashboard;
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class DashboardController : BaseApiController
{
private readonly ILogger<DashboardController> _logger;
private readonly DashboardService _dashboardService;
public DashboardController(
ILogger<DashboardController> logger,
DashboardService dashboardService
)
{
_logger = logger;
_dashboardService = dashboardService;
}
[HttpGet("~/api/dashboard")]
public object Index()
{
var data = _dashboardService.GetDashboardRestData(UserId);
return data;
}
[HttpGet("~/api/dashboard/income")]
public object Income(DateTime from, DateTime to, [AsGuid(true)] string? category)
{
var data = _dashboardService.GetDashboardIncomeData(UserId, from.StartOfDay(), to.EndOfDay(), category?.AsGuidNull());
return data;
}
[HttpGet("~/api/dashboard/outcome")]
public object Outcome(DateTime from, DateTime to, [AsGuid(true)] string? category)
{
var data = _dashboardService.GetDashboardOutcomeData(UserId, from.StartOfDay(), to.EndOfDay(), category?.AsGuidNull());
return data;
}
}