Compare commits
1 Commits
Feature/pr
...
Feature/no
| Author | SHA1 | Date | |
|---|---|---|---|
| 517f2d06ca |
88
ServiceHost/Areas/Admin/Controllers/CountController.cs
Normal file
88
ServiceHost/Areas/Admin/Controllers/CountController.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
using _0_Framework.Application;
|
||||||
|
using AccountManagement.Application.Contracts.Task;
|
||||||
|
using AccountManagement.Application.Contracts.Ticket;
|
||||||
|
using Company.Domain.WorkshopAccountAgg;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using ServiceHost.BaseControllers;
|
||||||
|
using WorkFlow.Application.Contracts.AdminWorkFlow;
|
||||||
|
|
||||||
|
namespace ServiceHost.Areas.Admin.Controllers;
|
||||||
|
|
||||||
|
public class CountController : AdminBaseController
|
||||||
|
{
|
||||||
|
private readonly IAuthHelper _authHelper;
|
||||||
|
private readonly IWorkshopAccountRepository _workshopAccountRepository;
|
||||||
|
private readonly IAdminWorkFlowApplication _adminWorkFlowApplication;
|
||||||
|
private readonly ITicketApplication _ticketApplication;
|
||||||
|
private readonly ITaskApplication _taskApplication;
|
||||||
|
private long _roleId;
|
||||||
|
|
||||||
|
public CountController(
|
||||||
|
IAuthHelper authHelper,
|
||||||
|
IWorkshopAccountRepository workshopAccountRepository,
|
||||||
|
IAdminWorkFlowApplication adminWorkFlowApplication,
|
||||||
|
ITicketApplication ticketApplication,
|
||||||
|
ITaskApplication taskApplication)
|
||||||
|
{
|
||||||
|
_authHelper = authHelper;
|
||||||
|
_workshopAccountRepository = workshopAccountRepository;
|
||||||
|
_ticketApplication = ticketApplication;
|
||||||
|
_taskApplication = taskApplication;
|
||||||
|
_adminWorkFlowApplication = adminWorkFlowApplication;
|
||||||
|
_roleId = authHelper.CurrentAccountInfo().RoleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("task")]
|
||||||
|
public async Task<IActionResult> GetTaskCount()
|
||||||
|
{
|
||||||
|
var currentAccountId = _authHelper.CurrentAccountId();
|
||||||
|
int taskCount = await _taskApplication.RequestedAndOverdueTasksCount(currentAccountId);
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
data = taskCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("ticket")]
|
||||||
|
public IActionResult GetTicketCount()
|
||||||
|
{
|
||||||
|
int ticketCount = _ticketApplication.GetAdminTicketsCount();
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
data = ticketCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("workflow")]
|
||||||
|
public async Task<IActionResult> GetWorkFlowCount()
|
||||||
|
{
|
||||||
|
var currentAccountId = _authHelper.CurrentAccountId();
|
||||||
|
var accountWorkshops = _workshopAccountRepository.GetList(currentAccountId).Select(x => x.WorkshopId).ToList();
|
||||||
|
var permissions = _authHelper.GetPermissions();
|
||||||
|
|
||||||
|
int workFlowCount = await _adminWorkFlowApplication.GetWorkFlowCountsForAdmin(accountWorkshops, currentAccountId, _roleId, permissions);
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
data = workFlowCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("checker")]
|
||||||
|
public async Task<IActionResult> GetCheckerCount()
|
||||||
|
{
|
||||||
|
int checkerCount = await _adminWorkFlowApplication.GetWorkFlowCountForChecker();
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
data = checkerCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user