public PermissionDtoContainer AddOperations(SecurityResourceDto resource, List <OperationDto> operationDtos)
        {
            PermissionDtoContainer responseContainer = new PermissionDtoContainer();
            PermissionTDataAccess  rtoDa             = new PermissionTDataAccess();
            List <PermissionDto>   insertList        = new List <PermissionDto>();

            foreach (var operationDto in operationDtos)
            {
                var relations = rtoDa.GetSingle(it => it.ResourceId == resource.SecurityResourceId && it.OperationId == operationDto.OperationId);
                if (relations == null)
                {
                    PermissionDto dto = new PermissionDto()
                    {
                        ResourceId  = resource.SecurityResourceId,
                        OperationId = operationDto.OperationId
                    };
                    insertList.Add(dto);
                    responseContainer.PermissionDtoList.Add(dto);
                }
                //else
                //{
                //    PermissionDto response = new PermissionDto();
                //    resource.SetIdentity(operationDto.Id);
                //    response.Response.AddBusinessException("ارتباط قبلا تعریف شده است!", BusinessExceptionEnum.Operational);

                //}
            }
            if (insertList.Count > 0)
            {
                rtoDa.Insert(insertList);
            }

            return(responseContainer);
        }
        public ResponseDto RemoveOperation(SecurityResourceDto resource, OperationDto operationDto)
        {
            ResponseDto           response     = new ResponseDto();
            PermissionTDataAccess permissionDa = new PermissionTDataAccess();
            var permission = permissionDa.GetSingle(it => it.ResourceId == resource.SecurityResourceId && it.OperationId == operationDto.OperationId);

            if (permission != null)
            {
                permissionDa.Delete(permission);
            }
            else
            {
                response.Response.AddBusinessException("این دسترسی تعریف نشده است!", BusinessExceptionEnum.Operational);
            }
            return(response);
        }
        public PermissionDto AddOperation(SecurityResourceDto resource, OperationDto operationDto)
        {
            PermissionDto         response = new PermissionDto();
            PermissionTDataAccess rtoDa    = new PermissionTDataAccess();
            var relations = rtoDa.GetSingle(it => it.ResourceId == resource.SecurityResourceId && it.OperationId == operationDto.OperationId);

            if (relations == null)
            {
                response = new PermissionDto()
                {
                    ResourceId  = resource.SecurityResourceId,
                    OperationId = operationDto.OperationId
                };
                rtoDa.Insert(response);
            }
            else
            {
                response.Response.AddBusinessException("ارتباط قبلا تعریف شده است!", BusinessExceptionEnum.Operational);
            }
            return(response);
        }