From af2c71ea0944fa977a27a5b4edf503e7cd3a20af Mon Sep 17 00:00:00 2001 From: MahanCh Date: Wed, 16 Jul 2025 14:48:27 +0330 Subject: [PATCH] add select workshop for admin api --- .../Client/Controllers/LoginController.cs | 36 +++++++++++++++++-- .../BaseControllers/AdminBaseController.cs | 2 +- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ServiceHost/Areas/Client/Controllers/LoginController.cs b/ServiceHost/Areas/Client/Controllers/LoginController.cs index 224eda38..4879df1c 100644 --- a/ServiceHost/Areas/Client/Controllers/LoginController.cs +++ b/ServiceHost/Areas/Client/Controllers/LoginController.cs @@ -1,13 +1,14 @@ using _0_Framework.Application; using CompanyManagment.App.Contracts.FinancialStatment; +using CompanyManagment.App.Contracts.Workshop; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Client.Controllers; -public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List Permissions,List Workshops,string WorkshopSlug,double DebtAmount); +public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List Permissions, List Workshops, string WorkshopSlug, double DebtAmount); -public class LoginController: ClientBaseController +public class LoginController : ClientBaseController { private readonly IAuthHelper _authHelper; private readonly IFinancialStatmentApplication _financialStatmentApplication; @@ -28,7 +29,7 @@ public class LoginController: ClientBaseController return Unauthorized(); var data = _authHelper.CurrentAccountInfo(); - if (data == null ) + if (data == null) return Unauthorized(); if (_authHelper.GetUserTypeWithId().userType is not UserType.Client and not UserType.SubAccount) @@ -46,4 +47,33 @@ public class LoginController: ClientBaseController ); return details; } + + /// + /// انتخاب کارگاه + /// + /// + /// + [HttpPost("select-workshop")] + public IActionResult SelectWorkshop(string slug) + { + var selectedWorkshop = _authHelper.CurrentAccountInfo().WorkshopList.FirstOrDefault(x => x.Slug == slug); + if (selectedWorkshop != null) + { + _authHelper.UpdateWorkshopSlugClaim(selectedWorkshop.Slug, selectedWorkshop.Name); + + return new JsonResult(new + { + isSuccedded = true, + message = "کارگاه مورد نظر شما انتخاب شد" + }); + } + else + { + return new JsonResult(new + { + isSuccedded = false, + message = "کارگاه مورد نظر شما یافت نشد" + }); + } + } } \ No newline at end of file diff --git a/ServiceHost/BaseControllers/AdminBaseController.cs b/ServiceHost/BaseControllers/AdminBaseController.cs index 3b046fc4..2ba56a71 100644 --- a/ServiceHost/BaseControllers/AdminBaseController.cs +++ b/ServiceHost/BaseControllers/AdminBaseController.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; namespace ServiceHost.BaseControllers; -//[Authorize(Policy = "AdminArea")] +[Authorize(Policy = "AdminArea")] [Area("Admin")] [ApiExplorerSettings(GroupName = "Admin")] [Route("api/[area]/[controller]")]