+ {
+ Success = false,
+ Error = ex.Message
+ };
+ }
+ }
+
+
+
+}
diff --git a/Company.Domain/_common/IUnitOfWork.cs b/Company.Domain/_common/IUnitOfWork.cs
index a51ae161..1c9b4cbf 100644
--- a/Company.Domain/_common/IUnitOfWork.cs
+++ b/Company.Domain/_common/IUnitOfWork.cs
@@ -2,7 +2,7 @@
public interface IUnitOfWork
{
- void Begin();
- void Commit();
- void Rollback();
+ void BeginAccountContext();
+ void CommitAccountContext();
+ void RollbackAccountContext();
}
\ No newline at end of file
diff --git a/CompanyManagment.EFCore/_common/UnitOfWork.cs b/CompanyManagment.EFCore/_common/UnitOfWork.cs
index 347aaf11..ddd47484 100644
--- a/CompanyManagment.EFCore/_common/UnitOfWork.cs
+++ b/CompanyManagment.EFCore/_common/UnitOfWork.cs
@@ -1,29 +1,30 @@
-using Company.Domain._common;
+using AccountMangement.Infrastructure.EFCore;
+using Company.Domain._common;
using Microsoft.EntityFrameworkCore.Storage;
namespace CompanyManagment.EFCore._common;
public class UnitOfWork : IUnitOfWork
{
- private readonly CompanyContext _context;
+ private readonly AccountContext _context;
private IDbContextTransaction _transaction;
- public UnitOfWork(CompanyContext context)
+ public UnitOfWork(AccountContext context)
{
_context = context;
}
- public void Begin()
+ public void BeginAccountContext()
{
_transaction = _context.Database.BeginTransaction();
}
- public void Commit()
+ public void CommitAccountContext()
{
_transaction?.Commit();
}
- public void Rollback()
+ public void RollbackAccountContext()
{
_transaction?.Rollback();
}
diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml
index e22b8350..1bbb0a7d 100644
--- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml
+++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/CreateRole.cshtml
@@ -922,7 +922,117 @@
-
+
+
+
+
+
+
+
+
@@ -1096,22 +1206,36 @@
\ No newline at end of file
diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Edit.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Edit.cshtml
index eda0fe89..dbfd19a0 100644
--- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Edit.cshtml
+++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Edit.cshtml
@@ -1,5 +1,53 @@
@model AccountManagement.Application.Contracts.Account.EditAccount
@{
+
}
-
+
+
+
+ آیا کاربر در پروگرام منیجر هم فعالیت میکند؟
+
+
+
+
diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml
index f3192c16..abaf0ff7 100644
--- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml
+++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml
@@ -934,6 +934,112 @@
+
+
+
@@ -1160,22 +1266,35 @@
\ No newline at end of file
diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs
index 5ffc6e4f..cbfffc33 100644
--- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs
+++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs
@@ -1,12 +1,16 @@
using _0_Framework.Application;
using _0_Framework.Application.Sms;
using AccountManagement.Application.Contracts.Account;
+using AccountManagement.Application.Contracts.ProgramManagerApiResult;
using AccountManagement.Application.Contracts.Role;
+using AccountManagement.Domain.AccountAgg;
+using AccountManagement.Domain.InternalApiCaller;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.SignalR;
+using Newtonsoft.Json;
using ServiceHost.Hubs;
namespace ServiceHost.Areas.Admin.Pages.Accounts.Account;
@@ -81,8 +85,42 @@ public class IndexModel : PageModel
public IActionResult OnGetEdit(long id)
- {
+ {
+
var account = _accountApplication.GetDetails(id);
+
+
+
+
+
+ var key = SecretKeys.ProgramManagerInternalApi;
+
+ var apiResult = InternalApiCaller.GetAsync(
+ $"api/user/{account.Id}",
+ key
+ );
+
+
+
+ // حالا نتیجه دیسریال شده در apiResult.Result قرار دارد
+ var result = apiResult.Result;
+
+ // مثل قبل:
+ if (result != null && result.isSuccess)
+ {
+ account.IsProgramManagerUser = (result.Data.accountId == account.Id);
+ }
+ else
+ {
+ account.IsProgramManagerUser = false;
+ }
+
+
+
+
+
+
+
account.Roles = _roleApplication.List();
return Partial("Edit", account);
}
@@ -100,7 +138,31 @@ public class IndexModel : PageModel
var rol = new List();
foreach (var item in role.MappedPermissions) rol.Add(item.Code);
- role.Permissions = rol;
+ var key = SecretKeys.ProgramManagerInternalApi;
+
+ var apiResult = InternalApiCaller.GetAsync(
+ "api/role",
+ key,
+ new Dictionary
+ {
+ { "RoleName", "" },
+
+ { "GozareshgirRoleId", role.Id }
+ }
+ );
+
+
+ role.Permissions = rol;
+ if (apiResult.Success)
+ {
+ if (apiResult.Result.isSuccess && apiResult.Result.data.role.Any())
+ {
+ var pmPermission = apiResult.Result.data.role.FirstOrDefault()!.permissions;
+ role.Permissions.AddRange(pmPermission);
+ }
+
+ }
+
return Partial("EditRole", role);
}
diff --git a/ServiceHost/Pages/Index.cshtml.cs b/ServiceHost/Pages/Index.cshtml.cs
index 20c52fa3..7d013f16 100644
--- a/ServiceHost/Pages/Index.cshtml.cs
+++ b/ServiceHost/Pages/Index.cshtml.cs
@@ -45,51 +45,3 @@ namespace ServiceHost.Pages
}
}
}
-
-public record SingleUserRespnsResult
-{
- public bool isSuccess { get; set; }
- public Data Data { get; set; }
-}
-public record Data
-
-{
- public long id { get; set; }
- ///
- /// نام و نام خانوادگی
- ///
- public string fullName { get; set; }
-
- ///
- /// نام کاربری
- ///
- public string userName { get; set; }
-
-
-
- ///
- /// مسیر عکس پروفایل
- ///
- public string profilePhotoPath { get; set; }
-
- ///
- /// شماره موبایل
- ///
- public string mobile { get; set; }
-
-
- ///
- /// فعال/غیر فعال بودن یوزر
- ///
- public bool isActive { get; set; }
-
- ///
- /// گذرواژه
- ///
- public string password { get; set; }
-
- ///
- /// ای دی اکانت کاربر در گزارشگیر
- ///
- public long? accountId { get; set; }
-}
diff --git a/ServiceHost/Program.cs b/ServiceHost/Program.cs
index 72430211..a14dba9e 100644
--- a/ServiceHost/Program.cs
+++ b/ServiceHost/Program.cs
@@ -36,6 +36,7 @@ using MongoDB.Driver;
using Parbad.Builder;
using Parbad.Gateway.Sepehr;
using Swashbuckle.AspNetCore.SwaggerUI;
+using AccountManagement.Domain.InternalApiCaller;
var builder = WebApplication.CreateBuilder(args);
@@ -333,7 +334,13 @@ builder.Services.AddParbad().ConfigureGateways(gateways =>
var app = builder.Build();
app.UseCors("AllowSpecificOrigins");
+#region InternalProgarmManagerApi
+var baseUrl = builder.Configuration["InternalProgramManagerApi:BaseUrl"];
+InternalApiCaller.SetBaseUrl(baseUrl);
+
+
+#endregion
#region Mahan
diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json
index 0f4feeef..17619b5f 100644
--- a/ServiceHost/appsettings.Development.json
+++ b/ServiceHost/appsettings.Development.json
@@ -41,11 +41,16 @@
},
"SmsSettings": {
"IsTestMode": true,
- "TestNumbers": [ "09116967898"
- //, "09116067106", "09114221321"
+ "TestNumbers": [
+ "09116967898"
+ //, "09116067106", "09114221321"
]
},
+ "InternalProgramManagerApi": {
+ "BaseUrl": "https://localhost:7032"
+ },
"SepehrGateWayTerminalId": 99213700
+
}
diff --git a/ServiceHost/appsettings.json b/ServiceHost/appsettings.json
index 0b602bb1..84af0c3e 100644
--- a/ServiceHost/appsettings.json
+++ b/ServiceHost/appsettings.json
@@ -36,6 +36,10 @@
"IsTestMode": false,
"TestNumbers": []
},
+
+ "InternalProgramManagerApi": {
+ "BaseUrl": "https://localhost:7032"
+ },
"SepehrGateWayTerminalId": 99213700
}