Add ProgramManager Context
This commit is contained in:
@@ -55,41 +55,42 @@ public class IndexModel : PageModel
|
||||
|
||||
|
||||
public IActionResult OnGetCreate()
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
var pmRolseSelectList = _roleApplication.GetPmRoleList(null).GetAwaiter().GetResult();
|
||||
var command = new CreateAccount
|
||||
{
|
||||
Roles = _roleApplication.List()
|
||||
};
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
Roles = _roleApplication.List(),
|
||||
RoleList = pmRolseSelectList,
|
||||
};
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
//var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
// { "GozareshgirRoleId", "" }
|
||||
// }
|
||||
//);
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
command.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
//if (response.Success)
|
||||
//{
|
||||
// if (response.Result.isSuccess)
|
||||
// {
|
||||
// command.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
return Partial("./Create", command);
|
||||
}
|
||||
|
||||
|
||||
public IActionResult OnPostCreate(CreateAccount command)
|
||||
{
|
||||
var result = _accountApplication.Create(command);
|
||||
var result = _accountApplication.Create(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public IActionResult OnPostCreateRole(CreateRole command)
|
||||
{
|
||||
var result = _roleApplication.Create(command);
|
||||
var result = _roleApplication.Create(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -112,55 +113,51 @@ public class IndexModel : PageModel
|
||||
|
||||
var account = _accountApplication.GetDetails(id);
|
||||
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
//var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
// $"api/user/{account.Id}",
|
||||
// key
|
||||
//);
|
||||
|
||||
|
||||
var result = _accountApplication.GetPmUserByAccountId(account.Id).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<SingleUserResponseResult>(
|
||||
$"api/user/{account.Id}",
|
||||
key
|
||||
);
|
||||
|
||||
|
||||
|
||||
// حالا نتیجه دیسریال شده در apiResult.Result قرار دارد
|
||||
var result = apiResult.Result;
|
||||
|
||||
// مثل قبل:
|
||||
if (result != null && result.isSuccess)
|
||||
if (result != null)
|
||||
{
|
||||
account.IsProgramManagerUser = (result.Data.accountId == account.Id && result.Data.isActive);
|
||||
account.UserRoles = apiResult.Result.Data.Roles;
|
||||
account.IsProgramManagerUser = (result.AccountId== account.Id && result.IsActive);
|
||||
account.UserRoles = result.Roles;
|
||||
}
|
||||
else
|
||||
{
|
||||
account.IsProgramManagerUser = false;
|
||||
}
|
||||
|
||||
var pmRolseSelectList = _roleApplication.GetPmRoleList(null).GetAwaiter().GetResult();
|
||||
account.RoleList = pmRolseSelectList;
|
||||
|
||||
//var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
var response = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
// { "GozareshgirRoleId", "" }
|
||||
// }
|
||||
//);
|
||||
|
||||
{ "GozareshgirRoleId", "" }
|
||||
}
|
||||
);
|
||||
//if (response.Success)
|
||||
//{
|
||||
// if (response.Result.isSuccess)
|
||||
// {
|
||||
// account.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (response.Result.isSuccess)
|
||||
{
|
||||
account.RoleList = new SelectList(response.Result.data.role, "id", "roleName");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -172,7 +169,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public JsonResult OnPostEdit(EditAccount command)
|
||||
{
|
||||
var result = _accountApplication.Edit(command);
|
||||
var result = _accountApplication.Edit(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -182,26 +179,27 @@ public class IndexModel : PageModel
|
||||
var rol = new List<int>();
|
||||
foreach (var item in role.MappedPermissions) rol.Add(item.Code);
|
||||
|
||||
var key = SecretKeys.ProgramManagerInternalApi;
|
||||
//var key = SecretKeys.ProgramManagerInternalApi;
|
||||
|
||||
var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
"api/role",
|
||||
key,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "RoleName", "" },
|
||||
//var apiResult = InternalApiCaller.GetAsync<RoleResponse>(
|
||||
// "api/role",
|
||||
// key,
|
||||
// new Dictionary<string, object>
|
||||
// {
|
||||
// { "RoleName", "" },
|
||||
|
||||
{ "GozareshgirRoleId", role.Id }
|
||||
}
|
||||
);
|
||||
// { "GozareshgirRoleId", role.Id }
|
||||
// }
|
||||
//);
|
||||
|
||||
var pmRoleResult = _roleApplication.GetPmRoleListToEdit(role.Id).GetAwaiter().GetResult();
|
||||
|
||||
role.Permissions = rol;
|
||||
if (apiResult.Success)
|
||||
if (pmRoleResult != null)
|
||||
{
|
||||
if (apiResult.Result.isSuccess && apiResult.Result.data.role.Any())
|
||||
if (pmRoleResult.Any())
|
||||
{
|
||||
var pmPermission = apiResult.Result.data.role.FirstOrDefault()!.permissions;
|
||||
var pmPermission = pmRoleResult.FirstOrDefault()!.Permissions;
|
||||
role.Permissions.AddRange(pmPermission);
|
||||
}
|
||||
|
||||
@@ -213,7 +211,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public JsonResult OnPostEditRole(EditRole command)
|
||||
{
|
||||
var result = _roleApplication.Edit(command);
|
||||
var result = _roleApplication.Edit(command).GetAwaiter().GetResult();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user