fix
This commit is contained in:
@@ -1,51 +1,52 @@
|
||||
namespace MyOffice.Web.Controllers;
|
||||
|
||||
using AutoMapper;
|
||||
using Core.Extensions;
|
||||
using Infrastructure.Attributes;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyOffice.Web.Models.Dashboard;
|
||||
using Services.Dashboard;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[DefaultFromBody]
|
||||
public class DashboardController : BaseApiController
|
||||
{
|
||||
private readonly ILogger<DashboardController> _logger;
|
||||
private readonly DashboardService _dashboardService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public DashboardController(
|
||||
ILogger<DashboardController> logger,
|
||||
DashboardService dashboardService
|
||||
DashboardService dashboardService,
|
||||
IMapper mapper
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_dashboardService = dashboardService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("~/api/dashboard")]
|
||||
public object Index()
|
||||
public ObjectResult Index()
|
||||
{
|
||||
var data = _dashboardService.GetDashboardRestData(UserId);
|
||||
|
||||
return data;
|
||||
return OkResponse(_mapper.Map<DashboardViewModel>(data));
|
||||
}
|
||||
|
||||
[HttpGet("~/api/dashboard/income")]
|
||||
public object Income(DateTime from, DateTime to, [AsGuid(true)] string? category)
|
||||
public ObjectResult Income(DateTime from, DateTime to, [AsGuid(true)] string? category)
|
||||
{
|
||||
var data = _dashboardService.GetDashboardIncomeData(UserId, from.StartOfDay(), to.EndOfDay(), category?.AsGuidNull());
|
||||
|
||||
return data;
|
||||
return OkResponse(_mapper.Map<DashboardIncomeDataViewModel>(data));
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("~/api/dashboard/outcome")]
|
||||
public object Outcome(DateTime from, DateTime to, [AsGuid(true)] string? category)
|
||||
public ObjectResult Outcome(DateTime from, DateTime to, [AsGuid(true)] string? category)
|
||||
{
|
||||
var data = _dashboardService.GetDashboardOutcomeData(UserId, from.StartOfDay(), to.EndOfDay(), category?.AsGuidNull());
|
||||
|
||||
return data;
|
||||
return OkResponse(_mapper.Map<DashboardIncomeDataViewModel>(data));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user