add select workshop for admin api
This commit is contained in:
@@ -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<int> Permissions,List<WorkshopClaim> Workshops,string WorkshopSlug,double DebtAmount);
|
||||
public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List<int> Permissions, List<WorkshopClaim> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// انتخاب کارگاه
|
||||
/// </summary>
|
||||
/// <param name="slug"></param>
|
||||
/// <returns></returns>
|
||||
[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 = "کارگاه مورد نظر شما یافت نشد"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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]")]
|
||||
|
||||
Reference in New Issue
Block a user