From 126cbff54fe4dec7809119cc0ba2e4e2d81a2536 Mon Sep 17 00:00:00 2001 From: mahan Date: Sun, 5 Oct 2025 11:41:56 +0330 Subject: [PATCH] add ticket and task count --- .../Admin/Controllers/LoginController.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ServiceHost/Areas/Admin/Controllers/LoginController.cs b/ServiceHost/Areas/Admin/Controllers/LoginController.cs index e3855c55..ca9a48c8 100644 --- a/ServiceHost/Areas/Admin/Controllers/LoginController.cs +++ b/ServiceHost/Areas/Admin/Controllers/LoginController.cs @@ -1,4 +1,6 @@ using _0_Framework.Application; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.Ticket; using AccountManagement.Application.Contracts.TicketAccessAccount; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; @@ -6,7 +8,8 @@ using ServiceHost.Controllers; namespace ServiceHost.Areas.Admin.Controllers; public record GetAdminProfileDetails(long Id, string Fullname, string Mobile, string RoleName, - List Permissions, long? PositionValue,UserType UserType,bool HasTicketAccess); + List Permissions, long? PositionValue,UserType UserType,bool HasTicketAccess, + int TicketCount,int TaskCount); public class LoginController:AdminBaseController { @@ -14,17 +17,22 @@ public class LoginController:AdminBaseController private readonly IAuthHelper _authHelper; private readonly ITicketAccessAccountApplication _ticketAccessAccount; - public LoginController(IAuthHelper authHelper, ITicketAccessAccountApplication ticketAccessAccount) + private readonly ITaskApplication _taskApplication; + private readonly ITicketApplication _ticketApplication; + + public LoginController(IAuthHelper authHelper, ITicketAccessAccountApplication ticketAccessAccount, ITaskApplication taskApplication, ITicketApplication ticketApplication) { _authHelper = authHelper; _ticketAccessAccount = ticketAccessAccount; + _taskApplication = taskApplication; + _ticketApplication = ticketApplication; } /// /// جزئیات پروفایل کاربر ادمین را برمی گرداند /// /// [HttpGet("Profile")] - public ActionResult GetProfile() + public async Task> GetProfile() { if (!_authHelper.IsAuthenticated()) return Unauthorized(); @@ -41,6 +49,8 @@ public class LoginController:AdminBaseController var hasTicketAccess = _ticketAccessAccount.HasTicketAccess(data.Id); + var taskCount = await _taskApplication.RequestedAndOverdueTasksCount(data.Id); + var ticketCount = _ticketApplication.GetAdminTicketsCount(); var details = new GetAdminProfileDetails( data.Id, data.Fullname, @@ -49,7 +59,8 @@ public class LoginController:AdminBaseController data.Permissions, data.PositionValue, userTypeWithId.userType, - hasTicketAccess + hasTicketAccess, + ticketCount, taskCount ); return details; }