From 1e3780be38555d550800c81d9695a90a8ee4e718 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Wed, 25 Jun 2025 15:01:29 +0330 Subject: [PATCH] change base controllers name - add dates and add admin select List --- .../Admin/Controllers/AccountController.cs | 25 +++++++++++++++++++ .../AdminMonthlyOverviewController.cs | 4 +-- .../Controllers/ContractingPartyController.cs | 2 +- .../Admin/Controllers/EmployeesController.cs | 4 +-- .../Admin/Controllers/EmployerController.cs | 2 +- .../Controllers/RepresentativeController.cs | 2 +- .../Admin/Controllers/WorkshopController.cs | 2 +- ...inController.cs => AdminBaseController.cs} | 2 +- .../BaseControllers/CameraBaseController.cs | 14 +++++++++++ .../BaseControllers/ClientBaseController.cs | 13 ++++++++++ .../BaseControllers/GeneralBaseController.cs | 13 ++++++++++ ServiceHost/Controllers/GeneralController.cs | 23 +++++++++++++++++ 12 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 ServiceHost/Areas/Admin/Controllers/AccountController.cs rename ServiceHost/BaseControllers/{AdminController.cs => AdminBaseController.cs} (84%) create mode 100644 ServiceHost/BaseControllers/CameraBaseController.cs create mode 100644 ServiceHost/BaseControllers/ClientBaseController.cs create mode 100644 ServiceHost/BaseControllers/GeneralBaseController.cs create mode 100644 ServiceHost/Controllers/GeneralController.cs diff --git a/ServiceHost/Areas/Admin/Controllers/AccountController.cs b/ServiceHost/Areas/Admin/Controllers/AccountController.cs new file mode 100644 index 00000000..314b8de5 --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/AccountController.cs @@ -0,0 +1,25 @@ +using AccountManagement.Application.Contracts.Account; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers; + +public class AccountController:AdminBaseController +{ + private readonly IAccountApplication _accountApplication; + + public AccountController(IAccountApplication accountApplication) + { + _accountApplication = accountApplication; + } + /// + /// سلکت لیست اکانت های ادمین برای جستجو + /// + /// + [HttpGet("select_list")] + public async Task>> GetAdminAccountsSelectList() + { + var res = await _accountApplication.GetAdminSelectList(); + return res; + } +} \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/AdminMonthlyOverviewController.cs b/ServiceHost/Areas/Admin/Controllers/AdminMonthlyOverviewController.cs index ed83b3fb..b4e4b800 100644 --- a/ServiceHost/Areas/Admin/Controllers/AdminMonthlyOverviewController.cs +++ b/ServiceHost/Areas/Admin/Controllers/AdminMonthlyOverviewController.cs @@ -3,9 +3,9 @@ using CompanyManagment.App.Contracts.AdminMonthlyOverview; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; -namespace ServiceHost.Api.Areas.Admin.Controllers; +namespace ServiceHost.Areas.Admin.Controllers; -public class AdminMonthlyOverviewController:AdminController +public class AdminMonthlyOverviewController:AdminBaseController { private readonly IAdminMonthlyOverviewApplication _adminMonthlyOverviewApplication; diff --git a/ServiceHost/Areas/Admin/Controllers/ContractingPartyController.cs b/ServiceHost/Areas/Admin/Controllers/ContractingPartyController.cs index 6202c7d6..3ddae363 100644 --- a/ServiceHost/Areas/Admin/Controllers/ContractingPartyController.cs +++ b/ServiceHost/Areas/Admin/Controllers/ContractingPartyController.cs @@ -6,7 +6,7 @@ using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Admin.Controllers; -public class ContractingPartyController : AdminController +public class ContractingPartyController : AdminBaseController { private readonly IPersonalContractingPartyApp _contractingPartyApplication; diff --git a/ServiceHost/Areas/Admin/Controllers/EmployeesController.cs b/ServiceHost/Areas/Admin/Controllers/EmployeesController.cs index dc05bcd6..2d735076 100644 --- a/ServiceHost/Areas/Admin/Controllers/EmployeesController.cs +++ b/ServiceHost/Areas/Admin/Controllers/EmployeesController.cs @@ -3,9 +3,9 @@ using CompanyManagment.App.Contracts.Employee; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; -namespace ServiceHost.Api.Areas.Admin.Controllers; +namespace ServiceHost.Areas.Admin.Controllers; -public class EmployeesController:AdminController +public class EmployeesController:AdminBaseController { private readonly IEmployeeApplication _employeeApplication; private readonly IAuthHelper _authHelper; diff --git a/ServiceHost/Areas/Admin/Controllers/EmployerController.cs b/ServiceHost/Areas/Admin/Controllers/EmployerController.cs index 78a7963c..0cefade3 100644 --- a/ServiceHost/Areas/Admin/Controllers/EmployerController.cs +++ b/ServiceHost/Areas/Admin/Controllers/EmployerController.cs @@ -5,7 +5,7 @@ using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Admin.Controllers; -public class EmployerController : AdminController +public class EmployerController : AdminBaseController { private readonly IEmployerApplication _employerApplication; diff --git a/ServiceHost/Areas/Admin/Controllers/RepresentativeController.cs b/ServiceHost/Areas/Admin/Controllers/RepresentativeController.cs index a57876d1..adc785b6 100644 --- a/ServiceHost/Areas/Admin/Controllers/RepresentativeController.cs +++ b/ServiceHost/Areas/Admin/Controllers/RepresentativeController.cs @@ -6,7 +6,7 @@ using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Admin.Controllers; -public class RepresentativeController : AdminController +public class RepresentativeController : AdminBaseController { private readonly IRepresentativeApplication _representativeApplication; diff --git a/ServiceHost/Areas/Admin/Controllers/WorkshopController.cs b/ServiceHost/Areas/Admin/Controllers/WorkshopController.cs index 099353e2..c096e573 100644 --- a/ServiceHost/Areas/Admin/Controllers/WorkshopController.cs +++ b/ServiceHost/Areas/Admin/Controllers/WorkshopController.cs @@ -4,7 +4,7 @@ using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Admin.Controllers; -public class WorkshopController:AdminController +public class WorkshopController: AdminBaseController { private readonly IWorkshopApplication _workshopApplication; diff --git a/ServiceHost/BaseControllers/AdminController.cs b/ServiceHost/BaseControllers/AdminBaseController.cs similarity index 84% rename from ServiceHost/BaseControllers/AdminController.cs rename to ServiceHost/BaseControllers/AdminBaseController.cs index b9e9c2ff..3b046fc4 100644 --- a/ServiceHost/BaseControllers/AdminController.cs +++ b/ServiceHost/BaseControllers/AdminBaseController.cs @@ -6,7 +6,7 @@ namespace ServiceHost.BaseControllers; [Area("Admin")] [ApiExplorerSettings(GroupName = "Admin")] [Route("api/[area]/[controller]")] -public class AdminController:ControllerBase +public class AdminBaseController:ControllerBase { } \ No newline at end of file diff --git a/ServiceHost/BaseControllers/CameraBaseController.cs b/ServiceHost/BaseControllers/CameraBaseController.cs new file mode 100644 index 00000000..b07e5d97 --- /dev/null +++ b/ServiceHost/BaseControllers/CameraBaseController.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace ServiceHost.Api.BaseControllers; + + +//[ApiExplorerSettings(GroupName = "Camera")] +[Authorize(Policy = "CameraArea")] +[Area("Camera")] +[Route("api/[area]/[controller]")] +public class CameraBaseController:ControllerBase +{ + +} \ No newline at end of file diff --git a/ServiceHost/BaseControllers/ClientBaseController.cs b/ServiceHost/BaseControllers/ClientBaseController.cs new file mode 100644 index 00000000..ae981a00 --- /dev/null +++ b/ServiceHost/BaseControllers/ClientBaseController.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace ServiceHost.Api.BaseControllers; + +//[Authorize(Policy = "ClientArea")] +[Area("Client")] +[ApiExplorerSettings(GroupName = "Client")] +[Route("api/[area]/[controller]")] +public class ClientBaseController: ControllerBase +{ + +} \ No newline at end of file diff --git a/ServiceHost/BaseControllers/GeneralBaseController.cs b/ServiceHost/BaseControllers/GeneralBaseController.cs new file mode 100644 index 00000000..7ef69f19 --- /dev/null +++ b/ServiceHost/BaseControllers/GeneralBaseController.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace ServiceHost.Api.BaseControllers; + + +[ApiExplorerSettings(GroupName = "General")] + +[Route("api/[controller]")] +public class GeneralBaseController:ControllerBase +{ + +} \ No newline at end of file diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs new file mode 100644 index 00000000..c2010fdf --- /dev/null +++ b/ServiceHost/Controllers/GeneralController.cs @@ -0,0 +1,23 @@ +using System.Globalization; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.Api.BaseControllers; + +namespace ServiceHost.Controllers; + +public class GeneralController:GeneralBaseController +{ + [HttpGet("Dates")] + public IActionResult GetDates() + { + var pc = new PersianCalendar(); + var now = DateTime.Now; + var currentYear = pc.GetYear(now); + var years = Enumerable.Range(1370, currentYear - 1370 + 1).ToList(); + var months = Enumerable.Range(1, 12).ToList(); + var currentDate = new { Year = currentYear, Month = pc.GetMonth(now), Day = pc.GetDayOfMonth(now) }; + return new JsonResult(new + { + years,months,currentDate + }); + } +} \ No newline at end of file