Ejemplo n.º 1
0
        public async Task <List <PermissionDto> > GetPermissions(long userId)
        {
            var getPermissions  = new List <PermissionDto>();
            var userPermissions = await _userPermissionRepository.GetUserPermissions();

            if (userPermissions != null && userPermissions.Count > 0)
            {
                foreach (var item in userPermissions)
                {
                    if (item.ParentId == null)
                    {
                        var childList = item.Permissions;
                        getPermissions.Add(new PermissionDto {
                            Id = item.Id, ParentId = null, DisplayTitle = item.PersianName
                        });
                        foreach (var subitem in childList)
                        {
                            getPermissions.Add(new PermissionDto {
                                Id = subitem.Id, ParentId = item.Id, DisplayTitle = subitem.PersianName
                            });
                        }
                    }
                }
            }
            return(getPermissions);
        }
Ejemplo n.º 2
0
        public Task <UpdateUserPermissionResponse> Handle(UpdateUserPermissionRequest request, CancellationToken cancellationToken)
        {
            var permission = _userPermissionRepository.GetUserPermissions(request.UserId).Where(it => it.PermissionID == request.PermissionId).FirstOrDefault();

            if (permission != null)
            {
                permission.UserPermissionValue = request.PermissionValue;
                _userPermissionRepository.UpdateUserPermission(permission);
            }
            else
            {
                _userPermissionRepository.AddUserPermission(new Domain.Entities.UserPermission
                {
                    UserID              = request.UserId,
                    PermissionID        = request.PermissionId,
                    UserPermissionValue = request.PermissionValue
                });
            }
            return(Task.FromResult(new UpdateUserPermissionResponse()
            {
                Success = true
            }));
        }
Ejemplo n.º 3
0
 public PagePermission GetUserPermissions(string userId, string moduleUrl, string moduleCode, int userTypeId)
 {
     return(_userPermissionRepository.GetUserPermissions(userId, moduleUrl, moduleCode, userTypeId));
 }