diff --git a/AccountManagement.Application/RoleApplication.cs b/AccountManagement.Application/RoleApplication.cs index 80a1af83..02d027c0 100644 --- a/AccountManagement.Application/RoleApplication.cs +++ b/AccountManagement.Application/RoleApplication.cs @@ -144,18 +144,14 @@ 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 diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Services/Role/PmRoleCommandService.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Services/Role/PmRoleCommandService.cs index 09d551f4..9ac4a2a8 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Services/Role/PmRoleCommandService.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Services/Role/PmRoleCommandService.cs @@ -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); + } } \ No newline at end of file diff --git a/Shared.Contracts/PmRole/Commands/IPmRoleCommandService.cs b/Shared.Contracts/PmRole/Commands/IPmRoleCommandService.cs index 3bd9e586..8be0cd83 100644 --- a/Shared.Contracts/PmRole/Commands/IPmRoleCommandService.cs +++ b/Shared.Contracts/PmRole/Commands/IPmRoleCommandService.cs @@ -3,4 +3,5 @@ public interface IPmRoleCommandService { Task<(bool, string)> Create(CreatePmRoleDto command); + Task<(bool, string)> Edit(CreatePmRoleDto command); } \ No newline at end of file