edit pmRole completed

This commit is contained in:
SamSys
2025-12-13 18:51:08 +03:30
parent a4bf6c952d
commit 955a6a3d21
3 changed files with 18 additions and 8 deletions

View File

@@ -144,20 +144,16 @@ public class RoleApplication : IRoleApplication
//اگر این نقش در پروگرام منیجر وجود داشت ویرایش کن
if (pmRoleResult != null)
{
try
{
var pmpermissionsData = pmPermissions.Where(x => x > 0).Select(x => new PmPermission(x)).ToList();
//pmRoleResult.Edit(command.Name, pmpermissionsData);
// await _pmRoleRepository.SaveChangesAsync();
}
catch (System.Exception)
var edit = new CreatePmRoleDto { RoleName = command.Name, Permissions = pmPermissions, GozareshgirRoleId = role.id };
var res = await _pmRoleCommandService.Edit(edit);
if (!res.Item1)
{
_unitOfWork.RollbackAccountContext();
return operation.Failed("خطا در ویرایش دسترسی ها در پروگرام منیجر");
}
//var parameters = new CreateProgramManagerRole
//{
// RoleName = command.Name,

View File

@@ -1,5 +1,6 @@
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Application.Modules.Roles.Commands.CreateRole;
using GozareshgirProgramManager.Application.Modules.Roles.Commands.EditRole;
using MediatR;
using Shared.Contracts.PmRole.Commands;
@@ -25,4 +26,16 @@ public class PmRoleCommandService: IPmRoleCommandService
var res = await _mediator.Send(request);
return (res.IsSuccess, res.ErrorMessage);
}
public async Task<(bool, string)> Edit(CreatePmRoleDto command)
{
var request = new EditRoleCommand
{
RoleName = command.RoleName,
Permissions = command.Permissions,
GozareshgirRoleId = command.GozareshgirRoleId
};
var res = await _mediator.Send(request);
return (res.IsSuccess, res.ErrorMessage);
}
}

View File

@@ -3,4 +3,5 @@
public interface IPmRoleCommandService
{
Task<(bool, string)> Create(CreatePmRoleDto command);
Task<(bool, string)> Edit(CreatePmRoleDto command);
}