public PermissionResult Assign(List <int> permissions, int userId, UserSessionObject currentUser)
        {
            bool       flag            = true;
            var        wrongIds        = new List <int>();
            List <int> alreadyAssigned = RelationUserPermissionRepository
                                         .GetRelationUserPermissionFor(userId)
                                         .Select(x => x.PermissionId)
                                         .ToList();
            PermissionResult result = null;

            foreach (int permissionId in permissions)
            {
                if (!alreadyAssigned.Contains(permissionId))
                {
                    var newLink = new RelationUserPermissionData
                    {
                        PermissionId     = permissionId,
                        UserId           = userId,
                        RefUserCreatedBy = currentUser.UserId
                    };
                    RelationUserPermissionRepository.SaveData(newLink);
                }
                else
                {
                    flag = false;
                    wrongIds.Add(permissionId);
                }
            }

            if (!flag)
            {
                result = new PermissionResult(false, PermissionResult.OperationType.Assign, wrongIds);
            }
            else
            {
                result = new PermissionResult(true, PermissionResult.OperationType.Assign);
            }

            return(result);
        }
        public PermissionResult Remove(List <int> permissions, int userId, UserSessionObject currentUser)
        {
            bool       flag            = true;
            var        wrongIds        = new List <int>();
            var        result          = new PermissionResult();
            List <int> alreadyAssigned = RelationUserPermissionRepository
                                         .GetRelationUserPermissionFor(userId)
                                         .Select(x => x.PermissionId)
                                         .ToList();

            foreach (int permissionId in permissions)
            {
                if (!alreadyAssigned.Contains(permissionId))
                {
                    flag = false;
                    wrongIds.Add(permissionId);
                }
                else
                {
                    var data = RelationUserPermissionRepository.GetRelationUserPermissionFor(userId, permissionId);
                    RelationUserPermissionRepository.DeleteById(data.Id, currentUser.UserId);
                }
            }

            if (!flag)
            {
                result = new PermissionResult(false, PermissionResult.OperationType.Remove, wrongIds);
            }
            else
            {
                result = new PermissionResult(true, PermissionResult.OperationType.Remove);
            }


            return(result);
        }