diff --git a/.forgejo/workflows/build-checkin.yml b/.forgejo/workflows/build-checkin.yml
deleted file mode 100644
index 3971e9df..00000000
--- a/.forgejo/workflows/build-checkin.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Checkin Service
-
-on:
- push:
- tags:
- - "checkin-dev[0-9]+.[0-9]+.[0-9]+"
- - "checkin-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-checkin
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/checkin-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.CheckInConsumer/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_CHECKIN "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-discipline.yml b/.forgejo/workflows/build-discipline.yml
deleted file mode 100644
index 767d775b..00000000
--- a/.forgejo/workflows/build-discipline.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Discipline Service
-
-on:
- push:
- tags:
- - "discipline-dev[0-9]+.[0-9]+.[0-9]+"
- - "discipline-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-discipline
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/discipline-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.Discipline.Service/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_DISCIPLINE "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-insignia.yml b/.forgejo/workflows/build-insignia.yml
deleted file mode 100644
index 7ddcbdbd..00000000
--- a/.forgejo/workflows/build-insignia.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Insignia Service
-
-on:
- push:
- tags:
- - "insignia-dev[0-9]+.[0-9]+.[0-9]+"
- - "insignia-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-insignia
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/insignia-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.Insignia/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_INSIGNIA "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-leave.yml b/.forgejo/workflows/build-leave.yml
deleted file mode 100644
index b1c9c168..00000000
--- a/.forgejo/workflows/build-leave.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Leave Service
-
-on:
- push:
- tags:
- - "leave-dev[0-9]+.[0-9]+.[0-9]+"
- - "leave-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-leave
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/leave-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.Leave/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_LEAVE "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-placement.yml b/.forgejo/workflows/build-placement.yml
deleted file mode 100644
index 351b1e59..00000000
--- a/.forgejo/workflows/build-placement.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Placement Service
-
-on:
- push:
- tags:
- - "placement-dev[0-9]+.[0-9]+.[0-9]+"
- - "placement-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-placement
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/placement-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.Placement.Service/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_PLACEMENT "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.forgejo/workflows/build-retirement.yml b/.forgejo/workflows/build-retirement.yml
deleted file mode 100644
index 257f68f2..00000000
--- a/.forgejo/workflows/build-retirement.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Build & Deploy Retirement Service
-
-on:
- push:
- tags:
- - "retirement-dev[0-9]+.[0-9]+.[0-9]+"
- - "retirement-dev[0-9]+.[0-9]+.[0-9]+*"
- workflow_dispatch:
-
-env:
- REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
- REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
- REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}
- IMAGE_VERSION: latest
- SERVICE_NAME: hrms-api-retirement
- DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }}
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Tag Version
- shell: bash
- run: |
- if [[ "${{ github.event_name }}" == "push" ]]; then
- VERSION=$(echo "${{ github.ref_name }}" | sed 's/retirement-dev//g')
- echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- else
- echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- fi
- - name: Login in to registry
- uses: docker/login-action@v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ env.REGISTRY_USERNAME }}
- password: ${{ env.REGISTRY_PASSWORD }}
-
- - name: Build and push docker image
- uses: docker/build-push-action@v5
- with:
- platforms: linux/amd64
- context: .
- file: ./BMA.EHR.Retirement.Service/Dockerfile
- tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }}
- push: true
-
- - name: Remote Deploy
- uses: appleboy/ssh-action@v1.2.1
- with:
- host: ${{ vars.SSH_DEPLOY_HOST }}
- port: ${{ vars.SSH_DEPLOY_PORT }}
- username: ${{ secrets.SSH_DEPLOY_USER }}
- password: ${{ secrets.SSH_DEPLOY_PASSWORD }}
- script: |
- cd ~/repo
- ./replace-env.sh API_RETIREMENT "${{ env.IMAGE_VERSION }}"
- ./deploy.sh ${{ env.SERVICE_NAME }}
-
- - name: Discord Notification
- if: always()
- run: |
- STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}"
- COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}"
- TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- curl -H "Content-Type: application/json" \
- -X POST \
- -d "{
- \"embeds\": [{
- \"title\": \"$STATUS\",
- \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\",
- \"color\": $COLOR,
- \"footer\": {
- \"text\": \"Release Notification\",
- \"icon_url\": \"https://example.com/success-icon.png\"
- },
- \"timestamp\": \"$TIMESTAMP\"
- }]
- }" \
- ${{ env.DISCORD_WEBHOOK }}
diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml
deleted file mode 100644
index ce4ee51d..00000000
--- a/.github/workflows/discord-notify.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: Discord PR Notify
-
-on:
- pull_request:
- types: [opened]
-
-jobs:
- discord:
- runs-on: ubuntu-latest
- steps:
- - name: Send Discord
- run: |
- curl -X POST "${{ secrets.DISCORD_WEBHOOK_PULLREQUEST }}" \
- -H "Content-Type: application/json" \
- -d '{
- "embeds": [{
- "title": "🔔 **Service:** ${{ github.repository }}",
- "description": "👤 **Author:** ${{ github.event.pull_request.user.login }}\n🌿 **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}\n📦 **Pull Request:** [#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})",
- "color": 5814783,
- "timestamp": "${{ github.event.pull_request.created_at }}"
- }]
- }'
diff --git a/.github/workflows/dockerhub-release-checkin.yaml b/.github/workflows/dockerhub-release-checkin.yaml
deleted file mode 100644
index b80c44f7..00000000
--- a/.github/workflows/dockerhub-release-checkin.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - CheckIn Consumer
-run-name: DockerHub Release - CheckIn Consumer by ${{ github.actor }}
-on:
- push:
- tags:
- - "checkin-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-checkin
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.CheckInConsumer/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR CheckIn Consumer
- org.opencontainers.image.description=HRMS CheckIn Consumer Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-command.yaml b/.github/workflows/dockerhub-release-command.yaml
deleted file mode 100644
index 571fd6c9..00000000
--- a/.github/workflows/dockerhub-release-command.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Command Service
-run-name: DockerHub Release - Command Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "command-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-command
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Command.Service/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Command Service
- org.opencontainers.image.description=HRMS Command API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-discipline.yaml b/.github/workflows/dockerhub-release-discipline.yaml
deleted file mode 100644
index f4642bd8..00000000
--- a/.github/workflows/dockerhub-release-discipline.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Discipline Service
-run-name: DockerHub Release - Discipline Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "discipline-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-discipline
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Discipline.Service/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Discipline Service
- org.opencontainers.image.description=HRMS Discipline API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-insignia.yaml b/.github/workflows/dockerhub-release-insignia.yaml
deleted file mode 100644
index 79d89963..00000000
--- a/.github/workflows/dockerhub-release-insignia.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Insignia Service
-run-name: DockerHub Release - Insignia Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "insignia-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-insignia
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Insignia/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Insignia Service
- org.opencontainers.image.description=HRMS Insignia API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-leave.yaml b/.github/workflows/dockerhub-release-leave.yaml
deleted file mode 100644
index f9c2e0ba..00000000
--- a/.github/workflows/dockerhub-release-leave.yaml
+++ /dev/null
@@ -1,119 +0,0 @@
-name: DockerHub Release - Leave Service
-run-name: DockerHub Release - Leave Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "leave-[0-9]+.[0-9]+.[0-9]+"
- # branches:
- # - main
- # - develop
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-leave
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- elif [[ $GITHUB_REF == 'refs/heads/'* ]]; then
- BRANCH_NAME=${GITHUB_REF#refs/heads/}
- IMAGE_VER="${BRANCH_NAME}-latest"
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Extract metadata for Docker
- id: meta
- uses: docker/metadata-action@v5
- with:
- images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
- tags: |
- type=ref,event=tag
- type=ref,event=branch
- type=raw,value=${{ steps.gen_ver.outputs.image_ver }}
- type=raw,value=latest,enable={{is_default_branch}}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Leave/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: ${{ steps.meta.outputs.labels }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Image digest
- run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-placement.yaml b/.github/workflows/dockerhub-release-placement.yaml
deleted file mode 100644
index d4e3dade..00000000
--- a/.github/workflows/dockerhub-release-placement.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Placement Service
-run-name: DockerHub Release - Placement Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "placement-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-placement
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Placement.Service/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Placement Service
- org.opencontainers.image.description=HRMS Placement API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-reportv2.yaml b/.github/workflows/dockerhub-release-reportv2.yaml
deleted file mode 100644
index 4dc73f3f..00000000
--- a/.github/workflows/dockerhub-release-reportv2.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Report Service
-run-name: DockerHub Release - Report Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "reportv2-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-reportv2
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Report.Service/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Report Service
- org.opencontainers.image.description=HRMS Report API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/dockerhub-release-retirement.yaml b/.github/workflows/dockerhub-release-retirement.yaml
deleted file mode 100644
index 50ace5cd..00000000
--- a/.github/workflows/dockerhub-release-retirement.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: DockerHub Release - Retirement Service
-run-name: DockerHub Release - Retirement Service by ${{ github.actor }}
-on:
- push:
- tags:
- - "retirement-[0-9]+.[0-9]+.[0-9]+"
- workflow_dispatch:
- inputs:
- IMAGE_VER:
- description: "Image version (e.g., latest, v1.0.0)"
- required: false
- default: "latest"
-
-env:
- DOCKERHUB_REGISTRY: docker.io
- IMAGE_NAME: hrms-api-retirement
- DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
-
-jobs:
- release-to-dockerhub:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
-
- - name: Generate version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT
- echo "Generated version: ${IMAGE_VER}"
-
- - name: Display version
- run: |
- echo "Git Ref: $GITHUB_REF"
- echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- registry: ${{env.DOCKERHUB_REGISTRY}}
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- file: BMA.EHR.Retirement.Service/Dockerfile
- platforms: linux/amd64
- push: true
- tags: |
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }}
- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- labels: |
- org.opencontainers.image.title=BMA EHR Retirement Service
- org.opencontainers.image.description=HRMS Retirement API Service
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Notify Discord on success
- if: success()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
-
- - name: Notify Discord on failure
- if: failure()
- env:
- IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }}
- run: |
- TAG_INFO="Tag: ${IMAGE_VER:-unknown}"
- REF_INFO="Ref: ${GITHUB_REF}"
- ACTOR_INFO="Actor: ${GITHUB_ACTOR}"
- MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}"
- curl -s -H "Content-Type: application/json" \
- -X POST \
- -d "{\"content\":\"${MSG}\"}" \
- "$DISCORD_WEBHOOK"
diff --git a/.github/workflows/release_Retirement.yaml b/.github/workflows/release_Retirement.yaml
index 3fd5bedf..6cdceae0 100644
--- a/.github/workflows/release_Retirement.yaml
+++ b/.github/workflows/release_Retirement.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "retirement-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "retirement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_checkin_consumer.yaml b/.github/workflows/release_checkin_consumer.yaml
index f9081264..31b015e6 100644
--- a/.github/workflows/release_checkin_consumer.yaml
+++ b/.github/workflows/release_checkin_consumer.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "consumer-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "consumer-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_command.yaml b/.github/workflows/release_command.yaml
index dba3012e..462ed688 100644
--- a/.github/workflows/release_command.yaml
+++ b/.github/workflows/release_command.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "command-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "command-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_discipline.yaml b/.github/workflows/release_discipline.yaml
index f4cb42da..0e8737f4 100644
--- a/.github/workflows/release_discipline.yaml
+++ b/.github/workflows/release_discipline.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "discipline-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "discipline-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml
index af497b37..124d1e9c 100644
--- a/.github/workflows/release_insignia.yaml
+++ b/.github/workflows/release_insignia.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "insignia-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "insignia-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_leave.yaml b/.github/workflows/release_leave.yaml
index 9b5e0014..b017222d 100644
--- a/.github/workflows/release_leave.yaml
+++ b/.github/workflows/release_leave.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "leave-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "leave-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
@@ -57,7 +57,7 @@ jobs:
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Remote Deployment
- uses: appleboy/ssh-action@v1
+ uses: appleboy/ssh-action@v0.1.8
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
diff --git a/.github/workflows/release_placement.yaml b/.github/workflows/release_placement.yaml
index 377cbaf4..d9c2f266 100644
--- a/.github/workflows/release_placement.yaml
+++ b/.github/workflows/release_placement.yaml
@@ -1,9 +1,9 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "placement-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "placement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
diff --git a/.github/workflows/release_report.yaml b/.github/workflows/release_report.yaml
index e529729b..9ba5a7c4 100644
--- a/.github/workflows/release_report.yaml
+++ b/.github/workflows/release_report.yaml
@@ -1,107 +1,107 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
- # push:
- # tags:
- # - "reportv2-[0-9]+.[0-9]+.[0-9]+"
+ push:
+ tags:
+ - "reportv2-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
- REGISTRY: docker.frappet.com
- IMAGE_NAME: ehr/bma-ehr-report-v2-service
- DEPLOY_HOST: frappet.com
- DEPLOY_PORT: 10102
- # COMPOSE_PATH: /home/frappet/docker/bma-ehr
- COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2
- TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-report-v2-service
+ DEPLOY_HOST: frappet.com
+ DEPLOY_PORT: 10102
+ # COMPOSE_PATH: /home/frappet/docker/bma-ehr
+ COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2
+ TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
- # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
- release-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set output tags
- id: vars
- run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- - name: Gen Version
- id: gen_ver
- run: |
- if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
- IMAGE_VER=${{ steps.vars.outputs.tag }}
- else
- IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
- fi
- if [[ $IMAGE_VER == '' ]]; then
- IMAGE_VER='test-vBeta'
- fi
- echo '::set-output name=image_ver::'$IMAGE_VER
- - name: Check Version
- run: |
- echo $GITHUB_REF
- echo ${{ steps.gen_ver.outputs.image_ver }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login in to registry
- uses: docker/login-action@v2
- with:
- registry: ${{env.REGISTRY}}
- username: ${{secrets.DOCKER_USER}}
- password: ${{secrets.DOCKER_PASS}}
- - name: Build and load local docker image
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- file: BMA.EHR.Report.Service/Dockerfile
- push: true
- tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+ # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set output tags
+ id: vars
+ run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER=${{ steps.vars.outputs.tag }}
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Check Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ file: BMA.EHR.Report.Service/Dockerfile
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- - name: Reload docker compose
- uses: appleboy/ssh-action@v0.1.8
- with:
- host: ${{env.DEPLOY_HOST}}
- username: frappet
- password: ${{ secrets.SSH_PASSWORD }}
- port: ${{env.DEPLOY_PORT}}
- script: |
- cd "${{env.COMPOSE_PATH}}"
- docker compose pull
- docker compose up -d
- echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- - name: Notify Discord Success
- if: success()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "✅ Deployment Success!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
- "color": 3066993,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/success-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: ${{env.DEPLOY_PORT}}
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker compose pull
+ docker compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
+ - name: Notify Discord Success
+ if: success()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "✅ Deployment Success!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
+ "color": 3066993,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/success-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
- - name: Notify Discord Failure
- if: failure()
- run: |
- curl -H "Content-Type: application/json" \
- -X POST \
- -d '{
- "embeds": [{
- "title": "❌ Deployment Failed!",
- "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
- "color": 15158332,
- "footer": {
- "text": "Release Notification",
- "icon_url": "https://example.com/failure-icon.png"
- },
- "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
- }]
- }' \
- ${{ secrets.DISCORD_WEBHOOK }}
+ - name: Notify Discord Failure
+ if: failure()
+ run: |
+ curl -H "Content-Type: application/json" \
+ -X POST \
+ -d '{
+ "embeds": [{
+ "title": "❌ Deployment Failed!",
+ "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
+ "color": 15158332,
+ "footer": {
+ "text": "Release Notification",
+ "icon_url": "https://example.com/failure-icon.png"
+ },
+ "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
+ }]
+ }' \
+ ${{ secrets.DISCORD_WEBHOOK }}
diff --git a/.gitignore b/.gitignore
index f60d8ec1..88bfb4ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,19 +16,6 @@
# Mono auto generated files
mono_crash.*
-# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
-.idea/
-*.iml
-*.ipr
-*.iws
-out/
-.idea_modules/
-atlassian-ide-plugin.xml
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -373,10 +360,4 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
-
-# VS Code C# Dev Kit cache
-*.lscache
-
-# Claude Code
-.claude/
\ No newline at end of file
+FodyWeavers.xsd
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/.name b/.idea/.idea.BMA.EHR.Solution/.idea/.name
new file mode 100644
index 00000000..888d8763
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/.name
@@ -0,0 +1 @@
+BMA.EHR.Solution
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml b/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
new file mode 100644
index 00000000..df87cf95
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml b/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
new file mode 100644
index 00000000..7b08163c
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml b/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml
new file mode 100644
index 00000000..4bb9f4d2
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml b/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml b/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml
new file mode 100644
index 00000000..3a284eaf
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/workspace.xml
@@ -0,0 +1,552 @@
+
+
+
+ BMA.EHR.CheckInConsumer/BMA.EHR.CheckInConsumer.csproj
+ BMA.EHR.CheckInConsumer/BMA.EHR.CheckInConsumer.csproj
+ BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
+ BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
+ BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj
+ BMA.EHR.Discipline.Service/BMA.EHR.Discipline.Service.csproj
+ BMA.EHR.Discipline.Service/BMA.EHR.Discipline.Service.csproj
+ BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
+ BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
+ BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
+ BMA.EHR.Leave/BMA.EHR.Leave.csproj
+ BMA.EHR.Leave/BMA.EHR.Leave.csproj
+ BMA.EHR.Leave/BMA.EHR.Leave.csproj
+ BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
+ BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
+ BMA.EHR.MetaData.Service/BMA.EHR.MetaData.Service.csproj
+ BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
+ BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
+ BMA.EHR.OrganizationEmployee.Service/BMA.EHR.OrganizationEmployee.Service.csproj
+ BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
+ BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
+ BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj
+ BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
+ BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
+ BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
+ BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
+ BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj
+ BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
+ BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
+ BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1724638841465
+
+
+ 1724638841465
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/BMA.EHR.Leave/Controllers/LeaveController.cs
+ 1152
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 6be3e592..fd9cf53a 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,60 +1,35 @@
{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
- "name": ".NET Core Launch (web)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/BMA.EHR.Leave/bin/Debug/net7.0/BMA.EHR.Leave.dll",
- "args": [],
- "cwd": "${workspaceFolder}/BMA.EHR.Leave",
- "stopAtEntry": false,
- // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
- "serverReadyAction": {
- "action": "openExternally",
- "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
- },
- "env": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "sourceFileMap": {
- "/Views": "${workspaceFolder}/Views"
- }
- },
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
- "name": ".NET Core Launch (web) - Insignia",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/BMA.EHR.Insignia/bin/Debug/net7.0/BMA.EHR.Insignia.dll",
- "args": [],
- "cwd": "${workspaceFolder}/BMA.EHR.Insignia",
- "stopAtEntry": false,
- // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
- "serverReadyAction": {
- "action": "openExternally",
- "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
- },
- "env": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "sourceFileMap": {
- "/Views": "${workspaceFolder}/Views"
- }
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/BMA.EHR.Leave.Service/bin/Debug/net7.0/BMA.EHR.Leave.Service.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/BMA.EHR.Leave.Service",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs
index 0b99a7b6..350b7a75 100644
--- a/BMA.EHR.Application/ApplicationServicesRegistration.cs
+++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs
@@ -53,7 +53,6 @@ namespace BMA.EHR.Application
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -61,8 +60,6 @@ namespace BMA.EHR.Application
services.AddTransient();
- services.AddTransient();
-
return services;
}
diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
index d306b3e9..02d03fe3 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
@@ -919,7 +919,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -934,7 +934,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -986,7 +986,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1001,7 +1001,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1423,7 +1423,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1440,7 +1440,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1534,7 +1534,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1550,7 +1550,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1603,7 +1603,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1832,7 +1832,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1849,7 +1849,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1905,7 +1905,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1922,7 +1922,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -1978,7 +1978,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -1995,7 +1995,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2051,7 +2051,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2068,7 +2068,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2124,7 +2124,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2141,7 +2141,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2197,7 +2197,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2214,7 +2214,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2270,7 +2270,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2287,7 +2287,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2340,7 +2340,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2355,7 +2355,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -2409,7 +2409,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2462,7 +2462,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2515,7 +2515,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2568,7 +2568,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2621,7 +2621,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2673,7 +2673,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2725,7 +2725,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
@@ -2994,7 +2994,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -3046,7 +3046,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
foreach (var edu in placementProfile.PlacementEducations)
{
var _res = await client.PostAsJsonAsync(apiUrlEdu, new
@@ -3083,7 +3083,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
foreach (var cer in placementProfile.PlacementCertificates)
{
var _res = await client.PostAsJsonAsync(apiUrlCer, new
@@ -3104,7 +3104,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = profileId,
@@ -3135,7 +3135,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3287,7 +3287,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3319,7 +3319,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3468,7 +3468,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3500,7 +3500,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3649,7 +3649,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3681,7 +3681,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -3832,7 +3832,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -3864,7 +3864,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4017,7 +4017,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4049,7 +4049,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4199,7 +4199,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4231,7 +4231,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -4382,7 +4382,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4409,7 +4409,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
@@ -4560,7 +4560,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -4587,7 +4587,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
@@ -4928,7 +4928,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -5085,7 +5085,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -5262,7 +5262,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5440,7 +5440,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5472,7 +5472,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -5626,7 +5626,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5805,7 +5805,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -5986,7 +5986,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6001,7 +6001,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6182,7 +6182,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6197,7 +6197,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6371,7 +6371,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6452,7 +6452,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
@@ -6549,7 +6549,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
@@ -6630,7 +6630,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
@@ -6719,7 +6719,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -6877,7 +6877,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -6906,7 +6906,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -7062,7 +7062,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Put, apiUrl);
var _res = await client.PutAsJsonAsync(apiUrl, new
{
@@ -7215,7 +7215,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -7244,7 +7244,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
@@ -7385,7 +7385,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7411,7 +7411,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7544,7 +7544,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7570,7 +7570,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7704,7 +7704,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7730,7 +7730,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -7864,7 +7864,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -7890,7 +7890,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8024,7 +8024,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8050,7 +8050,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8184,7 +8184,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8210,7 +8210,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8344,7 +8344,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8370,7 +8370,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8504,7 +8504,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8530,7 +8530,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl2);
var _res = await client.PostAsJsonAsync(apiUrl2, new
{
@@ -8663,7 +8663,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8806,7 +8806,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -8949,7 +8949,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9091,7 +9091,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9234,7 +9234,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
@@ -9612,7 +9612,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrl, new
@@ -9628,7 +9628,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
@@ -11388,7 +11388,7 @@ namespace BMA.EHR.Application.Repositories.Commands
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
foreach (var insignia in Insignias)
{
var _res = await client.PostAsJsonAsync(apiUrlInsig, new
diff --git a/BMA.EHR.Application/Repositories/DisciplineRepository.cs b/BMA.EHR.Application/Repositories/DisciplineRepository.cs
index 1933a2ce..2f4461e8 100644
--- a/BMA.EHR.Application/Repositories/DisciplineRepository.cs
+++ b/BMA.EHR.Application/Repositories/DisciplineRepository.cs
@@ -49,7 +49,7 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
refId = cronjobNoti.DisciplineComplaint_Profiles.Select(x => x.PersonId),
@@ -91,7 +91,7 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
refId = cronjobNoti.DisciplineInvestigate_ProfileComplaints.Select(x => x.PersonId),
@@ -132,7 +132,7 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
refId = cronjobNoti.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(x => x.PersonId),
diff --git a/BMA.EHR.Application/Repositories/GenericRepository.cs b/BMA.EHR.Application/Repositories/GenericRepository.cs
index d825ccaf..1f10ca37 100644
--- a/BMA.EHR.Application/Repositories/GenericRepository.cs
+++ b/BMA.EHR.Application/Repositories/GenericRepository.cs
@@ -53,18 +53,15 @@ namespace BMA.EHR.Application.Repositories
#region " For Call External API "
- protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey, CancellationToken cancellationToken = default)
+ protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
{
try
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", apiKey);
- var _res = await client.GetAsync(apiPath,cancellationToken: combinedCts.Token);
+ client.DefaultRequestHeaders.Add("api_key", apiKey);
+ var _res = await client.GetAsync(apiPath);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
@@ -80,13 +77,10 @@ namespace BMA.EHR.Application.Repositories
}
}
- protected async Task SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
+ protected async Task SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey)
{
try
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
// สร้าง request message
var request = new HttpRequestMessage(method, apiPath);
@@ -97,8 +91,8 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", apiKey);
- var _res = await client.SendAsync(request, combinedCts.Token);
+ client.DefaultRequestHeaders.Add("api_key", apiKey);
+ var _res = await client.SendAsync(request);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
@@ -115,13 +109,10 @@ namespace BMA.EHR.Application.Repositories
}
- public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
+ protected async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey)
{
try
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
var json = JsonConvert.SerializeObject(body);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
//stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
@@ -129,8 +120,8 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", apiKey);
- var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
+ client.DefaultRequestHeaders.Add("api_key", apiKey);
+ var _res = await client.PostAsync(apiPath, stringContent);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
@@ -146,13 +137,10 @@ namespace BMA.EHR.Application.Repositories
}
}
- protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
+ protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey)
{
try
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
var json = JsonConvert.SerializeObject(body);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
@@ -160,8 +148,8 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", apiKey);
- var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
+ client.DefaultRequestHeaders.Add("api_key", apiKey);
+ var _res = await client.PostAsync(apiPath, stringContent);
return _res.IsSuccessStatusCode;
}
}
diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
index 1c0741cb..7655e052 100644
--- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
+++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs
@@ -151,17 +151,6 @@ namespace BMA.EHR.Application.Repositories
}
}
- private static bool IsHigherLevel(BMA.EHR.Application.Responses.Profiles.ProfileInsignia? last, string request)
- {
- if (last == null)
- return true;
- else
- {
- var last_ins = last.Insignia?.ToLower().Trim() ?? "";
- return IsHigherLevel(last_ins, request);
- }
- }
-
private static bool IsHigherLevel(string last, string request)
{
if (request.Contains("ตริตาภรณ์ช้างเผือก"))
@@ -280,8 +269,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -297,10 +286,10 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
ProfileInsignia = p.ProfileInsignia,
@@ -406,85 +395,82 @@ namespace BMA.EHR.Application.Repositories
var jtmRoyal = await _dbContext.Set()
.FirstOrDefaultAsync(x => x.Name.Contains("จัตุรถาภรณ์มงกุฎไทย"));
- var s2_a = (from p in allProfilesByRoot
- where p.ProfileInsignia != null
- && p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
- x.InsigniaId.Value == bcpRoyal.Id)
- .ToList()
- .Count() == 0)
- select new
- {
- ProfileId = p.Id,
- p.CitizenId,
- p.FirstName,
- p.LastName,
- p.BirthDate,
- p.DateAppoint,
- Prefix = p.Prefix ?? "",
- FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
- Position = p.Position ?? "",
- Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- PosNo = p.PosNo,
- PositionLevelId = p.PosLevelId,
- PositionLevelName = p.PosLevel,
- PositionTypeId = p.PosTypeId,
- PositionTypeName = p.PosType,
- Gender = p.Gender ?? "",
- PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
- Amount = p.Amount ?? 0,
- RootId = p.RootId,
- RootDnaId = p.RootDnaId,
- Root = p.Root,
- Child1Id = p.Child1Id,
- Child1DnaId = p.Child1DnaId,
- Child1 = p.Child1,
- Child2Id = p.Child2Id,
- Child2DnaId = p.Child2DnaId,
- Child2 = p.Child2,
- Child3Id = p.Child3Id,
- Child3DnaId = p.Child3DnaId,
- Child3 = p.Child3,
- Child4Id = p.Child4Id,
- Child4DnaId = p.Child4DnaId,
- Child4 = p.Child4,
- LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
- ? null
- : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!
- .Insignia,
- LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
- ? Guid.Parse("00000000-0000-0000-0000-000000000000")
- : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
- Salary = p.Amount,
- SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
- p.Amount,
- IsHigherLevel =
- IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
- .OrderByDescending(x => x.Year)
- .FirstOrDefault(),
- "เบญจมาภรณ์ช้างเผือก"),
- FirstRecvInsigniaYear = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault()?.Year,
- ProfileType = p.ProfileType,
+ var s2 = (from p in allProfilesByRoot
+ where p.ProfileInsignia != null
+ && p.ProfileInsignia.Count > 0
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
+ x.InsigniaId.Value == bcpRoyal.Id)
+ .ToList()
+ .Count() == 0)
+ select new
+ {
+ ProfileId = p.Id,
+ p.CitizenId,
+ p.FirstName,
+ p.LastName,
+ p.BirthDate,
+ p.DateAppoint,
+ Prefix = p.Prefix ?? "",
+ FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
+ Position = p.Position ?? "",
+ Rank = p.PosLevel ?? "",
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ PosNo = p.PosNo,
+ PositionLevelId = p.PosLevelId,
+ PositionLevelName = p.PosLevel,
+ PositionTypeId = p.PosTypeId,
+ PositionTypeName = p.PosType,
+ Gender = p.Gender ?? "",
+ PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
+ Amount = p.Amount ?? 0,
+ RootId = p.RootId,
+ RootDnaId = p.RootDnaId,
+ Root = p.Root,
+ Child1Id = p.Child1Id,
+ Child1DnaId = p.Child1DnaId,
+ Child1 = p.Child1,
+ Child2Id = p.Child2Id,
+ Child2DnaId = p.Child2DnaId,
+ Child2 = p.Child2,
+ Child3Id = p.Child3Id,
+ Child3DnaId = p.Child3DnaId,
+ Child3 = p.Child3,
+ Child4Id = p.Child4Id,
+ Child4DnaId = p.Child4DnaId,
+ Child4 = p.Child4,
+ LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
+ ? null
+ : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!
+ .Insignia,
+ LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0
+ ? Guid.Parse("00000000-0000-0000-0000-000000000000")
+ : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
+ Salary = p.Amount,
+ SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
+ p.Amount,
+ IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
+ .Where(x => x.InsigniaId.Value != coinInsignia.Id)
+ .OrderByDescending(x => x.Year)
+ .FirstOrDefault().Insignia,
+ "เบญจมาภรณ์ช้างเผือก"),
+ FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault() == null ? 0 :
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault().Year,
+ ProfileType = p.ProfileType,
- MarkDiscipline = p.MarkDiscipline,
- MarkInsignia = p.MarkInsignia,
- MarkLeave = p.MarkLeave,
- MarkRate = p.MarkRate
- })
- .ToList();
-
- var s2 = s2_a
+ MarkDiscipline = p.MarkDiscipline,
+ MarkInsignia = p.MarkInsignia,
+ MarkLeave = p.MarkLeave,
+ MarkRate = p.MarkRate
+ })
+ .ToList()
.Where(x => (x.SalaryCondition >= 8340 && x.SalaryCondition < 10150) && !x.IsHigherLevel)
.Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 5)
.Select(p => new InsigniaResultSet
@@ -555,7 +541,7 @@ namespace BMA.EHR.Application.Repositories
var s3 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtmRoyal.Id)
.ToList()
.Count() == 0)
@@ -571,8 +557,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevel == null
? Guid.Parse("00000000-0000-0000-0000-000000000000")
@@ -590,21 +576,21 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"จัตุรถาภรณ์มงกุฎไทย"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
Amount = p.Amount ?? 0,
RootId = p.RootId,
@@ -794,8 +780,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -811,10 +797,10 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
ProfileInsignia = p.ProfileInsignia,
@@ -923,7 +909,7 @@ namespace BMA.EHR.Application.Repositories
var s2 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtmRoyal.Id)
.ToList()
.Count() == 0)
@@ -939,8 +925,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -956,21 +942,21 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"จัตุรถาภรณ์มงกุฎไทย"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount ?? 0,
Amount = p.Amount ?? 0,
RootId = p.RootId,
@@ -1065,7 +1051,7 @@ namespace BMA.EHR.Application.Repositories
var s3 = (from p in allProfilesByRoot
where p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
- && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id &&
+ && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id &&
x.InsigniaId.Value == jtcRoyal.Id)
.ToList()
.Count() == 0)
@@ -1081,8 +1067,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -1098,21 +1084,21 @@ namespace BMA.EHR.Application.Repositories
: p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList()
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id)
+ .Where(x => x.InsigniaId.Value != coinInsignia.Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"จัตุรถาภรณ์ช้างเผือก"),
FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
.FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
- .FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year)
+ .FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -1301,8 +1287,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo ?? "",
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -1311,24 +1297,24 @@ namespace BMA.EHR.Application.Repositories
Gender = p.Gender ?? "",
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
ProfileInsignia = p.ProfileInsignia,
PositionSalaryAmount = p.PositionSalaryAmount,
@@ -1426,9 +1412,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -1443,28 +1428,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo ?? "",
Gender = p.Gender == null ? "" : p.Gender,
@@ -1473,9 +1458,9 @@ namespace BMA.EHR.Application.Repositories
PositionTypeId = p.PosTypeId,
PositionTypeName = p.PosType,
IsHigherLevel = IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"เบญจมาภรณ์ช้างเผือก"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
@@ -1574,9 +1559,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -1591,28 +1575,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo ?? "",
Gender = p.Gender == null ? "" : p.Gender,
@@ -1622,14 +1606,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"จัตุรถาภรณ์มงกุฎไทย"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
@@ -1721,9 +1705,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -1738,28 +1721,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo ?? "",
Gender = p.Gender == null ? "" : p.Gender,
@@ -1769,14 +1752,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"จัตุรถาภรณ์ช้างเผือก"),
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
@@ -1975,9 +1958,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -1992,28 +1974,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2023,14 +2005,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ตริตาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2122,9 +2104,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -2139,28 +2120,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2170,14 +2151,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ตริตาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2185,7 +2166,7 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -2341,9 +2322,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -2358,28 +2338,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2389,14 +2369,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2404,7 +2384,7 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -2493,9 +2473,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -2510,28 +2489,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2541,14 +2520,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2556,7 +2535,7 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -2713,9 +2692,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -2730,28 +2708,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2761,14 +2739,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2776,7 +2754,7 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -2866,9 +2844,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -2883,28 +2860,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -2914,14 +2891,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -2929,14 +2906,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -3028,9 +3005,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -3045,28 +3021,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3076,14 +3052,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3091,14 +3067,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -3275,9 +3251,8 @@ namespace BMA.EHR.Application.Repositories
where p.PosType == "วิชาการ"
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -3292,28 +3267,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3323,14 +3298,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ตริตาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3338,14 +3313,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -3481,9 +3456,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -3498,28 +3472,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3529,14 +3503,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ตริตาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3544,14 +3518,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -3640,9 +3614,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -3657,28 +3630,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3688,14 +3661,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3703,14 +3676,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -3802,9 +3775,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -3819,28 +3791,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -3850,14 +3822,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -3865,14 +3837,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4048,9 +4020,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -4065,28 +4036,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4096,14 +4067,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4111,14 +4082,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4190,9 +4161,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -4207,28 +4177,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4238,14 +4208,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -4254,14 +4224,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4425,9 +4395,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -4442,28 +4411,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4473,14 +4442,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4488,14 +4457,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4585,9 +4554,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -4602,28 +4570,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4633,14 +4601,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -4649,14 +4617,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4747,9 +4715,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -4764,28 +4731,28 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -4795,14 +4762,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -4810,14 +4777,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -4991,9 +4958,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -5008,29 +4974,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5040,14 +5006,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5055,14 +5021,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -5159,9 +5125,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.ToList()
.Count() == 0)
select new
@@ -5176,29 +5141,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo == null ? "" : p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5208,14 +5173,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5223,14 +5188,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -5327,9 +5292,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -5344,29 +5308,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
@@ -5377,14 +5341,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
@@ -5393,12 +5357,12 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -5577,9 +5541,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -5594,29 +5557,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5626,14 +5589,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5641,14 +5604,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -5745,9 +5708,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.ToList()
.Count() == 0)
select new
@@ -5762,29 +5724,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5794,14 +5756,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5809,14 +5771,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -5913,9 +5875,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -5930,29 +5891,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -5962,14 +5923,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -5977,12 +5938,12 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
.FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date)
- .FirstOrDefault()?.Date,
+ .FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -6159,9 +6120,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -6176,29 +6136,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo == null ? "" : p.PosNo,
Gender = p.Gender == null ? "" : p.Gender,
@@ -6208,14 +6168,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ทวีติยาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6223,12 +6183,12 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -6317,9 +6277,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -6334,29 +6293,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? "" : p.Gender,
@@ -6366,14 +6325,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6381,14 +6340,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -6546,9 +6505,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -6563,29 +6521,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? "" : p.Gender,
@@ -6595,14 +6553,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6610,14 +6568,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -6708,9 +6666,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -6725,29 +6682,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? "" : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? "" : p.Gender,
@@ -6757,14 +6714,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6772,14 +6729,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -6871,9 +6828,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.ToList()
.Count() == 0)
select new
@@ -6888,29 +6844,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? "" : p.Gender,
@@ -6920,14 +6876,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -6935,14 +6891,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7113,9 +7069,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.ToList()
.Count() == 0)
select new
@@ -7130,29 +7085,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -7162,14 +7117,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์มงกุฎไทย"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -7177,14 +7132,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7275,9 +7230,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -7292,29 +7246,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -7324,14 +7278,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -7339,14 +7293,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7437,9 +7391,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.ToList()
.Count() == 0)
select new
@@ -7454,29 +7407,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -7486,14 +7439,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -7501,14 +7454,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7650,9 +7603,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -7667,29 +7619,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -7699,14 +7651,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"ประถมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -7714,14 +7666,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7818,9 +7770,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.ToList()
.Count() == 0)
select new
@@ -7835,29 +7786,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -7867,14 +7818,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาวชิรมงกุฎ"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -7882,14 +7833,14 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -7986,9 +7937,8 @@ namespace BMA.EHR.Application.Repositories
&& p.ProfileInsignia != null
&& p.ProfileInsignia.Count > 0
&& (p.ProfileInsignia.Where(x =>
- x.InsigniaId.HasValue &&
- x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id &&
- x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id)
+ x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id &&
+ x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id)
.ToList()
.Count() == 0)
select new
@@ -8003,29 +7953,29 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}",
Position = p.Position == null ? null : p.Position,
Rank = p.PosLevel ?? "",
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
- ProfileDateAppoint = p.DateAppoint!.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryPosition = p.PositionSalaryAmount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PosNo = p.PosNo,
Gender = p.Gender == null ? null : p.Gender,
@@ -8035,14 +7985,14 @@ namespace BMA.EHR.Application.Repositories
PositionTypeName = p.PosType,
IsHigherLevel =
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null
? true
: IsHigherLevel(p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value !=
- GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value !=
+ GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.OrderByDescending(x => x.Year)
- .FirstOrDefault(),
+ .FirstOrDefault().Insignia,
"มหาปรมาภรณ์ช้างเผือก"),
PositionLevel = p.PosLevel == null ? "" : p.PosLevel,
PositionType = p.PosType == null ? "" : p.PosType,
@@ -8050,12 +8000,12 @@ namespace BMA.EHR.Application.Repositories
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
.OrderBy(p => p.Date).FirstOrDefault() == null ? null :
p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร")
- .OrderBy(p => p.Date).FirstOrDefault()?.Date,
+ .OrderBy(p => p.Date).FirstOrDefault().Date,
FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
.OrderBy(x => x.Year).FirstOrDefault() == null ? 0 :
- p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id)
- .OrderBy(x => x.Year).FirstOrDefault()?.Year,
+ p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id)
+ .OrderBy(x => x.Year).FirstOrDefault().Year,
PositionSalaryAmount = p.PositionSalaryAmount,
Amount = p.Amount,
RootId = p.RootId,
@@ -8215,146 +8165,144 @@ namespace BMA.EHR.Application.Repositories
if (type.ToLower().Trim() == "officer")
{
var allOfficerProfilesByRoot = (await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken));
- if (allOfficerProfilesByRoot != null)
+
+ // calculate ตามแต่ละชั้น
+ var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level9_1 =
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type2_level9_2 =
+ allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+
+
+ // union result
+ foreach (var r in type_coin)
{
- // calculate ตามแต่ละชั้น
- var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level9_1 =
- allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type2_level9_2 =
- allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List();
- var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List();
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type4_level11)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type4_level10)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type3_level11)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type3_level10)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level9_2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level9_1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level8)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level7)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level6)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type2_level5)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level4)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level3)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ foreach (var r in type1_level1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
+
+ // ย้ายที่ตามที่ มอสแจ้ง
+ if (period.Round != 1)
+ {
+ var insigniaIdList = await _dbContext.Set()
+ .Include(x => x.InsigniaType)
+ .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย")
+ .Select(x => x.Id)
+ .ToListAsync();
- // union result
- foreach (var r in type_coin)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type4_level11)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type4_level10)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type3_level11)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type3_level10)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level9_2)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level9_1)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level8)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level7)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level6)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type2_level5)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type1_level4)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type1_level3)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type1_level2)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in type1_level1)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- // ย้ายที่ตามที่ มอสแจ้ง
- if (period.Round != 1)
- {
- var insigniaIdList = await _dbContext.Set()
- .Include(x => x.InsigniaType)
- .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย")
- .Select(x => x.Id)
- .ToListAsync();
-
-
- result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList();
- }
+ result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList();
}
}
else if (type.ToLower().Trim() == "employee")
@@ -8365,34 +8313,31 @@ namespace BMA.EHR.Application.Repositories
allEmployeeProfileByRoot = (await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken));
}
- if (allEmployeeProfileByRoot != null)
+ var type_coin = allEmployeeProfileByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allEmployeeProfileByRoot) : new List();
+
+ var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List();
+ var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List();
+
+ // union result
+ foreach (var r in type_coin)
{
- var type_coin = allEmployeeProfileByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allEmployeeProfileByRoot) : new List();
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
- var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List();
- var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List();
+ foreach (var r in employee_type2)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
+ }
- // union result
- foreach (var r in type_coin)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in employee_type2)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
-
- foreach (var r in employee_type1)
- {
- var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
- if (old == null)
- result_candidate.Add(r);
- }
+ foreach (var r in employee_type1)
+ {
+ var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
+ if (old == null)
+ result_candidate.Add(r);
}
}
else
@@ -8612,7 +8557,7 @@ namespace BMA.EHR.Application.Repositories
if (period == null)
throw new Exception(GlobalMessages.CoinPeriodNotFound);
- var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint.HasValue && x.DateAppoint != null)
+ var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint != null)
.Select(p => new
{
ProfileId = p.Id,
@@ -8625,8 +8570,8 @@ namespace BMA.EHR.Application.Repositories
FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}",
Position = p.Position ?? "",
Rank = p.PosLevel ?? "",
- ProfileDateAppoint = p.DateAppoint!.Value,
- GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0),
+ ProfileDateAppoint = p.DateAppoint.Value,
+ GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
PosNo = p.PosNo,
PositionLevelId = p.PosLevelId,
PositionLevelName = p.PosLevel,
@@ -8635,24 +8580,24 @@ namespace BMA.EHR.Application.Repositories
Gender = p.Gender ?? "",
LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? "" :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().Insignia,
LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
.FirstOrDefault() == null ? Guid.Empty :
p.ProfileInsignia
- .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id)
- .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId,
+ .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id)
+ .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId,
Salary = p.Amount,
SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 :
- p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
+ p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary
- .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29))
- .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount :
+ .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29))
+ .OrderByDescending(x => x.Order).FirstOrDefault().Amount :
p.Amount,
PositionSalaryAmount = p.PositionSalaryAmount,
ProfileInsignia = p.ProfileInsignia,
diff --git a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
index 2e550d71..5fbbb8a1 100644
--- a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs
@@ -2,11 +2,8 @@
using BMA.EHR.Domain.Models.Base;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json;
using System.IO.Pipes;
-using System.Net.Http.Headers;
using System.Security.Claims;
-using System.Text;
namespace BMA.EHR.Application.Repositories.Leaves
{
@@ -46,38 +43,6 @@ namespace BMA.EHR.Application.Repositories.Leaves
#region " Methods "
- public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default)
- {
- try
- {
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
- var json = JsonConvert.SerializeObject(body);
- var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", apiKey);
- var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token);
- if (_res.IsSuccessStatusCode)
- {
- var _result = await _res.Content.ReadAsStringAsync();
-
- return _result;
- }
- return string.Empty;
- }
- }
- catch
- {
- throw;
- }
- }
-
-
public virtual async Task> GetAllAsync()
{
return await _dbSet.ToListAsync();
@@ -103,24 +68,6 @@ namespace BMA.EHR.Application.Repositories.Leaves
return entity;
}
- public virtual async Task> AddRangeAsync(List entities)
- {
- foreach (var entity in entities)
- {
- if (entity is EntityBase)
- {
- (entity as EntityBase).CreatedUserId = UserId ?? "";
- (entity as EntityBase).CreatedFullName = FullName ?? "System Administrator";
- (entity as EntityBase).CreatedAt = DateTime.Now;
- }
- }
-
- await _dbSet.AddRangeAsync(entities);
- await _dbContext.SaveChangesAsync();
-
- return entities;
- }
-
public virtual async Task UpdateAsync(T entity)
{
if (entity is EntityBase)
diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs
index add1361b..4d3eedd9 100644
--- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs
@@ -1,7 +1,6 @@
using Amazon.S3.Model;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Messaging;
-using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests;
@@ -9,7 +8,6 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-using System.Collections.Concurrent;
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
@@ -24,12 +22,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
private readonly IConfiguration _configuration;
private readonly EmailSenderService _emailSenderService;
- ///
- /// Keyed locks to serialize get-or-create for LeaveBeginning rows by (ProfileId, LeaveYear, LeaveTypeId).
- /// Prevents duplicate inserts when concurrent requests (e.g. UI calling /user/check twice) hit the same key.
- ///
- private static readonly ConcurrentDictionary _getOrAddLocks = new();
-
#endregion
#region " Constructor and Destuctor "
@@ -86,8 +78,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task UpdateLeaveUsageAsync(int year, Guid typeId, Guid userId, double day)
{
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
if (pf == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -97,7 +88,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.LeaveType)
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
- if (data == null)
+ if(data == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
@@ -106,81 +97,35 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
await _dbContext.SaveChangesAsync();
}
- public async Task UpdateLeaveCountAsync(int year, Guid typeId, Guid userId, int count)
+
+ public async Task GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
{
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
if (pf == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
+ var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
+
+ var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
+
var data = await _dbContext.Set()
.Include(x => x.LeaveType)
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
if (data == null)
- {
- throw new Exception(GlobalMessages.DataNotFound);
- }
- data.LeaveCount += count;
-
- await _dbContext.SaveChangesAsync();
- }
-
- public async Task ProcessEarlyLeaveRequest(int year)
- {
- // Get Early Leave Request (กรองตามปีงบประมาณ: 1 ต.ค. (year-1) – 30 ก.ย. (year))
- var fiscalStart = new DateTime(year - 1, 10, 1);
- var fiscalEnd = new DateTime(year, 9, 30);
-
- var leaveReq = await _dbContext.Set()
- .Include(x => x.Type)
- .Where(x => x.LeaveStatus == "APPROVE")
- .Where(x => x.LeaveStartDate.Date <= fiscalEnd && x.LeaveEndDate.Date >= fiscalStart)
- .ToListAsync();
-
- foreach (var leave in leaveReq)
- {
- await GetByYearAndTypeIdForUserWithUpdateAsync(year, leave.Type.Id, leave.KeycloakUserId);
- }
- }
-
- public async Task ProcessEarlyLeaveRequestSchedule()
- {
- int year = DateTime.Now.Year;
- await ProcessEarlyLeaveRequest(year);
- }
-
- public async Task GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
- {
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
- if (pf == null)
- {
- throw new Exception(GlobalMessages.DataNotFound);
- }
-
- var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
-
- var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
-
- LeaveBeginning Factory()
{
var limit = 0.0;
- var prev = _dbContext.Set()
+ var prev = await _dbContext.Set()
.Include(x => x.LeaveType)
- .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
-
- // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
- var isCurrentYear = DateTime.Now.Year == year;
-
+ .FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
var prevRemain = 0.0;
if (prev != null)
{
- prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
+ prevRemain = prev.LeaveDays - prev.LeaveDaysUsed;
}
if (govAge >= 180)
@@ -201,7 +146,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
limit = 0.0;
}
- return new LeaveBeginning
+ data = new LeaveBeginning
{
LeaveYear = year,
LeaveTypeId = typeId,
@@ -210,378 +155,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
FirstName = pf.FirstName,
LastName = pf.LastName,
LeaveDaysUsed = 0,
- LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
- RootDnaId = pf.RootDnaId,
- Child1DnaId = pf.Child1DnaId,
- Child2DnaId = pf.Child2DnaId,
- Child3DnaId = pf.Child3DnaId,
- Child4DnaId = pf.Child4DnaId
+ LeaveDays = leaveType?.Code == "LV-005" ? limit : 0
};
- }
- return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
- }
-
- public async Task GetByYearAndTypeIdForUserWithUpdateAsync(int year, Guid typeId, Guid userId)
- {
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
- if (pf == null)
- {
- throw new Exception(GlobalMessages.DataNotFound);
- }
-
- var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
-
- var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
-
-
- var limit = 0.0;
-
- var prev = _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
-
- var prevRemain = 0.0;
-
-
-
- if (prev != null)
- {
- prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
- }
-
- if (govAge >= 180)
- {
- if (govAge >= 3650)
- {
- limit = 10 + prevRemain;
- if (limit > 30) limit = 30;
- }
- else
- {
- limit = 10 + prevRemain;
- if (limit > 20) limit = 20;
- }
- }
- else
- {
- limit = 0.0;
- }
-
- var data = await _dbContext.Set()
- .Where(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id)
- .FirstOrDefaultAsync();
-
- if (data != null)
- {
- data.LeaveDays = leaveType?.Code == "LV-005" ? limit : 0;
+ _dbContext.Set().Add(data);
await _dbContext.SaveChangesAsync();
}
- // return new LeaveBeginning
- // {
- // LeaveYear = year,
- // LeaveTypeId = typeId,
- // ProfileId = pf.Id,
- // Prefix = pf.Prefix,
- // FirstName = pf.FirstName,
- // LastName = pf.LastName,
- // LeaveDaysUsed = 0,
- // LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
- // RootDnaId = pf.RootDnaId,
- // Child1DnaId = pf.Child1DnaId,
- // Child2DnaId = pf.Child2DnaId,
- // Child3DnaId = pf.Child3DnaId,
- // Child4DnaId = pf.Child4DnaId
- // };
return data;
-
- }
-
-
- public async Task GetByYearAndTypeIdForUser(int year, Guid typeId, GetProfileByKeycloakIdDto? pf)
- {
- var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
-
- var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
-
- LeaveBeginning Factory()
- {
- var limit = 0.0;
-
- var prev = _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
-
- // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
- var isCurrentYear = DateTime.Now.Year == year;
-
- var prevRemain = 0.0;
- if (prev != null)
- {
- prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
- }
-
- if (govAge >= 180)
- {
- if (govAge >= 3650)
- {
- limit = 10 + prevRemain;
- if (limit > 30) limit = 30;
- }
- else
- {
- limit = 10 + prevRemain;
- if (limit > 20) limit = 20;
- }
- }
- else
- {
- limit = 0.0;
- }
-
- return new LeaveBeginning
- {
- LeaveYear = year,
- LeaveTypeId = typeId,
- ProfileId = pf.Id,
- Prefix = pf.Prefix,
- FirstName = pf.FirstName,
- LastName = pf.LastName,
- LeaveDaysUsed = 0,
- LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
- RootDnaId = pf.RootDnaId,
- Child1DnaId = pf.Child1DnaId,
- Child2DnaId = pf.Child2DnaId,
- Child3DnaId = pf.Child3DnaId,
- Child4DnaId = pf.Child4DnaId
- };
- }
-
- return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
}
- public async Task GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId)
- {
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
- if (pf == null)
- {
- return null;
- }
-
- var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
-
- var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
-
- LeaveBeginning Factory()
- {
- var limit = 0.0;
-
- var prev = _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
-
- // คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
- var isCurrentYear = DateTime.Now.Year == year;
-
- var prevRemain = 0.0;
- if (prev != null)
- {
- prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
- }
-
- if (govAge >= 180)
- {
- if (govAge >= 3650)
- {
- limit = 10 + prevRemain;
- if (limit > 30) limit = 30;
- }
- else
- {
- limit = 10 + prevRemain;
- if (limit > 20) limit = 20;
- }
- }
- else
- {
- limit = 0.0;
- }
-
- return new LeaveBeginning
- {
- LeaveYear = year,
- LeaveTypeId = typeId,
- ProfileId = pf.Id,
- Prefix = pf.Prefix,
- FirstName = pf.FirstName,
- LastName = pf.LastName,
- LeaveDaysUsed = 0,
- LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
- RootDnaId = pf.RootDnaId,
- Child1DnaId = pf.Child1DnaId,
- Child2DnaId = pf.Child2DnaId,
- Child3DnaId = pf.Child3DnaId,
- Child4DnaId = pf.Child4DnaId
- };
- }
-
- return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
- }
-
- ///
- /// Get-or-create a LeaveBeginning row for (ProfileId, LeaveYear, LeaveTypeId) with concurrency protection.
- /// Uses a keyed SemaphoreSlim to serialize within-process requests, and re-queries after acquiring the lock.
- /// If a cross-process insert wins (unique index violation), the duplicate key exception is caught and the row
- /// created by the winner is returned.
- ///
- private async Task GetOrAddForUserAsync(int year, Guid typeId, Guid profileId, Func factory)
- {
- var key = $"{profileId}_{year}_{typeId}";
- var semaphore = _getOrAddLocks.GetOrAdd(key, _ => new SemaphoreSlim(1, 1));
- await semaphore.WaitAsync();
- try
- {
- // Re-query inside the lock — another thread may have created it while we waited.
- var existing = await _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
- if (existing != null)
- {
- return existing;
- }
-
- var entity = factory();
- _dbContext.Set().Add(entity);
- try
- {
- await _dbContext.SaveChangesAsync();
- return entity;
- }
- catch (DbUpdateException)
- {
- // Cross-process/cross-server race hit the unique index (IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId).
- // Detach the failed insert and return the row created by the winner.
- _dbContext.Detach(entity);
- var winner = await _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
- return winner;
- }
- }
- finally
- {
- semaphore.Release();
- }
- }
-
- public async Task> GetAllByYearAndTypeAsync(int year, Guid typeId, List userIdList)
- {
-
- var updateList = new List();
- var result = new List();
-
- var beginningList = await _dbContext.Set()
- .Include(x => x.LeaveType)
- .Where(x => x.LeaveYear == year && x.LeaveTypeId == typeId)
- .ToListAsync();
-
- foreach (var pf in userIdList)
- {
- //var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(id, AccessToken);
- //if (pf == null)
- //{
- // continue; // Goto Next Id
- //}
-
- var profile = await _userProfileRepository.GetProfileByProfileIdAsync(pf.Id, AccessToken);
- if (profile == null)
- {
- return null;
- }
-
- var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
-
- var leaveType = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == typeId);
-
- var data = beginningList.FirstOrDefault(x => x.ProfileId == pf.Id);
-
- if (data == null)
- {
- var limit = 0.0;
-
- var prev = await _dbContext.Set()
- .Include(x => x.LeaveType)
- .FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
-
- var prevRemain = 0.0;
- if (prev != null)
- {
- prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
- }
-
- if (govAge >= 180)
- {
- if (govAge >= 3650)
- {
- limit = 10 + prevRemain;
- if (limit > 30) limit = 30;
- }
- else
- {
- limit = 10 + prevRemain;
- if (limit > 20) limit = 20;
- }
- }
- else
- {
- limit = 0.0;
- }
-
- data = new LeaveBeginning
- {
- LeaveYear = year,
- LeaveTypeId = typeId,
- ProfileId = pf.Id,
- Prefix = pf.Prefix,
- FirstName = pf.FirstName,
- LastName = pf.LastName,
- LeaveDaysUsed = 0,
- LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
- RootDnaId = profile.RootDnaId,
- Child1DnaId = profile.Child1DnaId,
- Child2DnaId = profile.Child2DnaId,
- Child3DnaId = profile.Child3DnaId,
- Child4DnaId = profile.Child4DnaId
- };
-
- updateList.Add(data);
- }
- result.Add(data);
- }
- if (!updateList.Any())
- {
- await _dbContext.Set().AddRangeAsync(updateList);
- await _dbContext.SaveChangesAsync();
- }
- return result;
- }
- }
-
- public class ProfileData
- {
- public Guid Id { get; set; } = Guid.Empty;
-
- public string Prefix { get; set; } = string.Empty;
-
- public string FirstName { get; set; } = string.Empty;
-
- public string LastName { get; set; } = string.Empty;
-
- public DateTime? DateStart { get; set; } = null;
-
- public DateTime? DateAppoint { get; set; } = null;
}
}
diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
index 54a80a41..25595c5f 100644
--- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs
@@ -8,11 +8,8 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-using System.IO.Compression;
using System.Net.Http.Headers;
using System.Net.Http.Json;
-using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
-using BMA.EHR.Domain.Models.Leave.TimeAttendants;
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
@@ -31,10 +28,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
private readonly MinIOLeaveService _minIOService;
private readonly LeaveBeginningRepository _leaveBeginningRepository;
- private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository;
-
- private readonly UserDutyTimeRepository _userDutyTimeRepository;
- private readonly DutyTimeRepository _dutyTimeRepository;
private readonly string URL = string.Empty;
@@ -50,10 +43,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
EmailSenderService emailSenderService,
IApplicationDBContext appDbContext,
MinIOLeaveService minIOService,
- LeaveBeginningRepository leaveBeginningRepository,
- ProcessUserTimeStampRepository processUserTimeStampRepository,
- UserDutyTimeRepository userDutyTimeRepository,
- DutyTimeRepository dutyTimeRepository) : base(dbContext, httpContextAccessor)
+ LeaveBeginningRepository leaveBeginningRepository) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
@@ -63,15 +53,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
_emailSenderService = emailSenderService;
_appDbContext = appDbContext;
- _userDutyTimeRepository = userDutyTimeRepository;
- _dutyTimeRepository = dutyTimeRepository;
-
-
URL = (_configuration["VITE_URL_MGT"]).Replace("/api/v1", "");
Console.WriteLine($"URL : {URL}");
_minIOService = minIOService;
_leaveBeginningRepository = leaveBeginningRepository;
- _processUserTimeStampRepository = processUserTimeStampRepository;
}
#endregion
@@ -267,8 +252,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task> GetLeaveRequestByYearAsync(int year, Guid userId)
{
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
if (profile == null)
{
@@ -289,57 +273,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
- public async Task> GetLeaveRequestByYearForAdminAsync(int year, string role, string? nodeId, int? node)
- {
- var rawData = _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE");
- //.ToListAsync();
- if (year != 0)
- {
- var startFiscalDate = new DateTime(year - 1, 10, 1);
- var endFiscalDate = new DateTime(year, 9, 30);
- rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
- }
-
- if (role == "OWNER")
- {
- node = null;
- }
- if (role == "OWNER" || role == "CHILD")
- {
- rawData = rawData
- .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
- }
- else if (role == "BROTHER")
- {
- rawData = rawData
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
- }
- else if (role == "ROOT")
- {
- rawData = rawData
- .Where(x => x.RootDnaId == Guid.Parse(nodeId!));
- }
- // else if (role == "PARENT")
- // {
- // rawData = rawData
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
- // }
- else if (role == "NORMAL")
- {
- rawData = rawData
- .Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
- }
-
- return await rawData.ToListAsync();
- }
-
public async Task> GetLeaveRequestByUserIdAsync(Guid keycloakUserId, int year, Guid type, string status)
{
var rawData = _dbContext.Set().AsQueryable().AsNoTracking()
@@ -347,12 +280,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId);
if (year != 0)
- {
- var startFiscalDate = new DateTime(year - 1, 10, 1);
- var endFiscalDate = new DateTime(year, 9, 30);
- rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
- }
- //rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
+ rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@@ -368,7 +296,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var rawData = _dbContext.Set().AsNoTracking()
.Include(x => x.Type)
.Where(x => x.LeaveStatus != "DRAFT")
- .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
+ .OrderByDescending(x => x.CreatedAt)
.AsQueryable();
if (year != 0)
@@ -394,15 +322,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
var rawData = _dbContext.Set().AsNoTracking()
.Include(x => x.Type)
.Where(x => x.LeaveStatus != "DRAFT")
- .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
+ .OrderByDescending(x => x.CreatedAt)
.AsQueryable();
- // fix issue : 1830
+
if (year != 0)
- {
- var startFiscalDate = new DateTime(year - 1, 10, 1);
- var endFiscalDate = new DateTime(year, 9, 30);
- rawData = rawData.Where(x => x.LeaveStartDate >= startFiscalDate && x.LeaveStartDate <= endFiscalDate);
- }
+ rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@@ -425,30 +349,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData = rawData
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
}
- else if (role == "BROTHER")
- {
- rawData = rawData
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
- }
else if (role == "ROOT")
{
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
}
- // else if (role == "PARENT")
- // {
- // rawData = rawData
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
- // }
else if (role == "NORMAL")
{
rawData = rawData
- .Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
+ .Where(x => node == 0 ? x.Child1DnaId == null : (node == 1 ? x.Child2DnaId == null : (node == 2 ? x.Child3DnaId == null : (node == 3 ? x.Child4DnaId == null : true))));
}
@@ -461,7 +370,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
.Where(x => keycloakIdList.Contains(x.KeycloakUserId))
.Where(x => x.LeaveStatus != "DRAFT")
- .OrderByDescending(x =>(x.DateSendLeave ?? x.CreatedAt))
+ .OrderByDescending(x => x.CreatedAt)
.AsQueryable();
if (year != 0)
@@ -510,8 +419,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
public async Task GetSumLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
- // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(keycloakUserId, AccessToken);
- var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(keycloakUserId, AccessToken);
+ var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(keycloakUserId, AccessToken);
if (pf == null)
throw new Exception(GlobalMessages.DataNotFound);
@@ -536,7 +444,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
.ToListAsync();
- return data.Sum(x => x.LeaveTotal) + (beginningLeave == null ? 0 : (beginningLeave.LeaveDaysUsed ?? 0.0));
+ return data.Sum(x => x.LeaveTotal) + (beginningLeave == null ? 0 : beginningLeave.LeaveDaysUsed);
}
//public async Task GetSumApproveLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
@@ -567,12 +475,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
- public async Task GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
+ public async Task GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId,DateTime beforeDate)
{
var data = await _dbContext.Set().AsQueryable().AsNoTracking()
.Include(x => x.Type)
.Where(x => x.LeaveStartDate.Date < beforeDate.Date)
- //.Where(x => x.CreatedAt < beforeDate)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
@@ -583,22 +490,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return data;
}
- public async Task GetLastLeaveRequestByTypeForUserAsync2(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- //.Where(x => x.LeaveStartDate.Date < beforeDate.Date)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < beforeDate)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
- .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt))
- .FirstOrDefaultAsync();
-
- return data;
- }
-
public async Task> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status, string role, string? nodeId, int? node)
{
var rawData = _dbContext.Set().AsNoTracking()
@@ -606,14 +497,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.LeaveStatus == "DELETE" || x.LeaveStatus == "DELETING")
.AsQueryable();
- // if (year != 0)
- // rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (year != 0)
- {
- var startFiscalDate = new DateTime(year - 1, 10, 1);
- var endFiscalDate = new DateTime(year, 9, 30);
- rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
- }
+ rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
if (type != Guid.Empty)
rawData = rawData.Where(x => x.Type.Id == type);
@@ -631,30 +516,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData = rawData
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
}
- else if (role == "BROTHER")
- {
- rawData = rawData
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
- }
else if (role == "ROOT")
{
rawData = rawData
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
}
- // else if (role == "PARENT")
- // {
- // rawData = rawData
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
- // }
else if (role == "NORMAL")
{
rawData = rawData
- .Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
+ .Where(x => node == 0 ? x.Child1DnaId == null : (node == 1 ? x.Child2DnaId == null : (node == 2 ? x.Child3DnaId == null : (node == 3 ? x.Child4DnaId == null : true))));
}
return await rawData.ToListAsync();
@@ -664,8 +534,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
{
try
{
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? "");
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -682,24 +551,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
// TODO : Update ไปตาราง beginning
if (data.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
{
-
- var toDay = data.LeaveStartDate.Date;
- var thisYear = data.LeaveStartDate.Year;
- if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
- {
- thisYear = thisYear + 1;
- }
- await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal);
- // update leave count ลดลง 1 ครั้ง
- await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1);
-
+ await _leaveBeginningRepository.UpdateLeaveUsageAsync(data.LeaveStartDate.Year, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal);
var _baseAPI = _configuration["API"];
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{data.Id}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
@@ -709,8 +568,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
//var _result = await _res.Content.ReadAsStringAsync();
}
- }
-
+ }
+
// Send Noti
var noti = new Notification
@@ -741,8 +600,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -758,24 +616,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
// TODO : Update ไปตาราง beginning
if (rawData.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
{
-
- var toDay = rawData.LeaveStartDate.Date;
- var thisYear = rawData.LeaveStartDate.Year;
- if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
- {
- thisYear = thisYear + 1;
- }
-
- await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal);
- // update leave count ลดลง 1 ครั้ง
- await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1);
+ await _leaveBeginningRepository.UpdateLeaveUsageAsync(rawData.LeaveStartDate.Year, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal);
var _baseAPI = _configuration["API"];
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{rawData.Id}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
@@ -804,7 +652,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.OrderBy(x => x.Seq)
.ToList();
- foreach (var commander in commanders)
+ foreach(var commander in commanders)
{
var noti1 = new Notification
{
@@ -819,7 +667,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
await _appDbContext.SaveChangesAsync();
-
+
}
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
@@ -830,8 +678,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -918,7 +765,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
rawData.LeaveStatus = "NEW";
- rawData.DateSendLeave = DateTime.Now; // Update วันที่ยื่นลาเป็นวันที่ปัจจุบัน
//rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
@@ -942,40 +788,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
.OrderBy(x => x.Seq)
.FirstOrDefault();
-
- // fix: If no commander, skip notification
- if (firstCommander != null)
+ // Send Notification
+ var noti1 = new Notification
{
- // Send Notification
- var noti1 = new Notification
- {
- Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
- ReceiverUserId = firstCommander!.ProfileId,
- Type = "",
- Payload = $"{URL}/leave/detail/{id}",
- };
- _appDbContext.Set().Add(noti1);
- }
- else
- {
- // มีแต่ approver อย่างเดียว
- var firstApprover = rawData.Approvers
- .Where(x => x.ApproveType!.ToUpper() == "APPROVER")
- .OrderBy(x => x.Seq)
- .FirstOrDefault();
- if(firstApprover != null)
- {
- // Send Notification
- var noti2 = new Notification
- {
- Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
- ReceiverUserId = firstApprover!.ProfileId,
- Type = "",
- Payload = $"{URL}/leave/detail/{id}",
- };
- _appDbContext.Set().Add(noti2);
- }
- }
+ Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
+ ReceiverUserId = firstCommander!.ProfileId,
+ Type = "",
+ Payload = $"{URL}/leave/detail/{id}",
+ };
+ _appDbContext.Set().Add(noti1);
await _appDbContext.SaveChangesAsync();
}
@@ -1045,9 +866,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
approver.ApproveStatus = "APPROVE";
approver.Comment = reason;
- approver.LastUpdateFullName = FullName ?? "";
- approver.LastUpdateUserId = userId.ToString("D");
- approver.LastUpdatedAt = DateTime.Now;
+
//await _dbContext.SaveChangesAsync();
if (approver.Seq != maxSeq)
@@ -1137,9 +956,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
approver.ApproveStatus = "REJECT";
approver.Comment = reason;
- approver.LastUpdateFullName = FullName ?? "";
- approver.LastUpdateUserId = userId.ToString("D");
- approver.LastUpdatedAt = DateTime.Now;
+
if (approver.Seq != maxSeq)
{
@@ -1197,17 +1014,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- // ถ้าไม่มี commander ข้ามไปเช็ค approver ได้เลย
- var commanders = rawData.Approvers
- .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
- .OrderBy(x => x.Seq)
- .ToList();
- if (commanders.Count > 0 && commanders != null)
+ if (rawData.ApproveStep != "st3")
{
- if (rawData.ApproveStep != "st3")
- {
- throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
- }
+ throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
}
// check commander approve
@@ -1235,9 +1044,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
approver.ApproveStatus = "APPROVE";
approver.Comment = reason;
- approver.LastUpdateFullName = FullName ?? "";
- approver.LastUpdateUserId = userId.ToString("D");
- approver.LastUpdatedAt = DateTime.Now;
+
if (approver.Seq != maxSeq)
{
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
@@ -1256,8 +1063,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
}
else
{
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken);
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -1269,17 +1075,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
await UpdateWithTrackingAsync(rawData);
- var toDay = rawData.LeaveStartDate.Date;
- var thisYear = rawData.LeaveStartDate.Year;
- if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
- {
- thisYear = thisYear + 1;
- }
-
// TODO : Update ไปตาราง beginning
- await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, rawData.LeaveTotal);
- // update leave count เพิ่มขึ้น 1 ครั้ง
- await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, 1);
+ await _leaveBeginningRepository.UpdateLeaveUsageAsync(rawData.LeaveStartDate.Year, rawData.Type.Id, rawData.KeycloakUserId, rawData.LeaveTotal);
var _baseAPI = _configuration["API"];
@@ -1290,7 +1087,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = profile.Id,
@@ -1303,8 +1100,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
status = "approve",
reason = rawData.LeaveDetail,
leaveId = rawData.Id,
- leaveSubTypeName = rawData.LeaveSubTypeName,
- coupleDayLevelCountry = rawData.CoupleDayLevelCountry,
});
// var _result = await _res.Content.ReadAsStringAsync();
}
@@ -1315,7 +1110,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileEmployeeId = profile.Id,
@@ -1328,8 +1123,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
status = "approve",
reason = rawData.LeaveDetail,
leaveId = rawData.Id,
- leaveSubTypeName = rawData.LeaveSubTypeName,
- coupleDayLevelCountry = rawData.CoupleDayLevelCountry,
});
}
}
@@ -1339,133 +1132,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
}
await _appDbContext.SaveChangesAsync();
- // ปรับสถานะการลงเวลา
- var currentDate = rawData.LeaveStartDate;
- var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
- if (defaultRound is null)
- {
- throw new Exception("ไม่พบรอบการลงเวลาทำงาน Default");
- }
- var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id, currentDate);
- var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
- var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
+ // insert to process timestamp
+
- // TODO : รอดุึงรอบที่ผูกกับ user
- var duty = userRound ?? defaultRound;
-
-
- if (rawData.LeaveStartDate.Date == rawData.LeaveEndDate.Date)
- {
- var processCheckIn = await _dbContext.Set()
- .Where(x => x.KeycloakUserId == rawData.KeycloakUserId)
- .Where(x => x.CheckIn.Date == rawData.LeaveStartDate.Date)
- .FirstOrDefaultAsync();
-
-
- if (processCheckIn is not null)
- {
- var startTimeMorning = duty.StartTimeMorning;
- var endTimeMorning = duty.EndTimeMorning;
- var startTimeAfterNoon = duty.StartTimeAfternoon;
- var endTimeAfterNoon = duty.EndTimeAfternoon;
-
- // var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm"));
- // var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime1}");
- // var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning1}");
-
- switch (rawData.LeaveRange.Trim().ToUpper())
- {
- case "MORNING":
- var checkIn = DateTime.Parse(processCheckIn.CheckIn.ToString("yyyy-MM-dd HH:mm"));
- var startAfternoon = DateTime.Parse($"{processCheckIn.CheckIn.ToString("yyyy-MM-dd")} {startTimeAfterNoon}");
- if (checkIn <= startAfternoon)
- processCheckIn.CheckInStatus = "NORMAL";
- else
- {
- processCheckIn.CheckInStatus = "LATE";
- }
- break;
- case "AFTERNOON":
- if (processCheckIn.CheckOut is not null)
- {
- var checkOut = DateTime.Parse(processCheckIn.CheckOut.Value.ToString("yyyy-MM-dd HH:mm"));
- var endMorning = DateTime.Parse($"{processCheckIn.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}");
- if(checkOut >= endMorning)
- processCheckIn.CheckOutStatus = "NORMAL";
- else
- {
- processCheckIn.CheckOutStatus = "ABSENT";
- }
- }
- break;
- case "ALL":
- processCheckIn.CheckInStatus = "NORMAL";
- processCheckIn.CheckOutStatus = "NORMAL";
- break;
- default:
- break;
- }
- }
- await _dbContext.SaveChangesAsync();
- }
- else
- {
- var startTimeMorning = duty.StartTimeMorning;
- var endTimeMorning = duty.EndTimeMorning;
- var startTimeAfterNoon = duty.StartTimeAfternoon;
- var endTimeAfterNoon = duty.EndTimeAfternoon;
-
- var from = rawData.LeaveStartDate.Date;
- var to = rawData.LeaveEndDate.Date;
- for (var day = from.Date; day <= to.Date; day = day.AddDays(1))
- {
- var processCheckIn = await _dbContext.Set()
- .Where(x => x.KeycloakUserId == rawData.KeycloakUserId)
- .Where(x => x.CheckIn.Date == day.Date)
- .FirstOrDefaultAsync();
-
- if (processCheckIn is not null)
- {
- switch (rawData.LeaveRange.Trim().ToUpper())
- {
- case "MORNING":
- var checkIn = DateTime.Parse(processCheckIn.CheckIn.ToString("yyyy-MM-dd HH:mm"));
- var startAfternoon = DateTime.Parse($"{processCheckIn.CheckIn.ToString("yyyy-MM-dd")} {startTimeAfterNoon}");
- if (checkIn <= startAfternoon)
- processCheckIn.CheckInStatus = "NORMAL";
- else
- {
- processCheckIn.CheckInStatus = "LATE";
- }
- break;
- case "AFTERNOON":
- if (processCheckIn.CheckOut is not null)
- {
- var checkOut = DateTime.Parse(processCheckIn.CheckOut.Value.ToString("yyyy-MM-dd HH:mm"));
- var endMorning = DateTime.Parse($"{processCheckIn.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}");
- if (checkOut >= endMorning)
- processCheckIn.CheckOutStatus = "NORMAL";
- else
- {
- processCheckIn.CheckOutStatus = "ABSENT";
- }
- }
- break;
- case "ALL":
- processCheckIn.CheckInStatus = "NORMAL";
- if (processCheckIn.CheckOut is not null)
- {
- processCheckIn.CheckOutStatus = "NORMAL";
- }
- break;
- default:
- break;
- }
- }
- }
- await _dbContext.SaveChangesAsync();
- }
-
// Send Noti
var noti = new Notification
{
@@ -1491,17 +1160,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
throw new Exception(GlobalMessages.DataNotFound);
}
- // ถ้าไม่มี commander ข้ามไปเช็ค approver ได้เลย
- var commanders = rawData.Approvers
- .Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
- .OrderBy(x => x.Seq)
- .ToList();
- if (commanders.Count > 0 && commanders != null)
+ if (rawData.ApproveStep != "st3")
{
- if (rawData.ApproveStep != "st3")
- {
- throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
- }
+ throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
}
// check commander approve
@@ -1529,9 +1190,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
approver.ApproveStatus = "REJECT";
approver.Comment = reason;
- approver.LastUpdateFullName = FullName ?? "";
- approver.LastUpdateUserId = userId.ToString("D");
- approver.LastUpdatedAt = DateTime.Now;
+
if (approver.Seq != maxSeq)
{
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
@@ -1550,8 +1209,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
}
else
{
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken);
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
@@ -1585,7 +1243,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
//.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
- //.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
+ //.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
.Where(x => x.LeaveStatus != "DRAFT") // fix issue : #1524
.ToListAsync();
@@ -1624,7 +1282,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
KeycloakUserId = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value,
LeaveTypeId = b.LeaveTypeId,
LeaveTypeCode = b.LeaveType!.Code,
- SumLeaveDay = b.LeaveDaysUsed ?? 0.0
+ SumLeaveDay = b.LeaveDaysUsed
});
}
}
@@ -1796,178 +1454,83 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
KeycloakUserId = grp.Key.KeycloakUserId,
LeaveTypeId = grp.Key.LeaveTypeId,
LeaveTypeCode = grp.Key.LeaveTypeCode,
- SumLeaveDay = grp.Sum(x => x.LeaveTotal),
- CountLeaveDay = grp.Count()
+ SumLeaveDay = grp.Sum(x => x.LeaveTotal)
})
.ToList();
return res;
}
- public async Task> GetSumApproveLeaveByRootAndRange(DateTime startDate, DateTime endDate, string type, string role, string? nodeId, int? node, string? nodeIdByReq, int? nodeByReq)
+ public async Task> GetSumApproveLeaveByRootAndRange(DateTime startDate, DateTime endDate, string type, string role, string? nodeId, int? node)
{
+ // var _nodeId = Guid.Parse(nodeId);
var data = new List();
- data = await _dbContext.Set().AsQueryable()
- .Include(x => x.Type)
- .Where(x => x.ProfileType == type.Trim().ToUpper())
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
- // กรองตามสิทธิ์ admin ก่อน
- if (role == "CHILD")
+ if (role == "OWNER" || role == "CHILD")
{
- data = data.Where(x =>
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId) :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId) :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId) :
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId) :
- node == null ? true : true
- ).ToList();
- }
- else if (role == "BROTHER")
- {
- data = data.Where(x =>
- node == 4 ? x.Child3DnaId == Guid.Parse(nodeId) :
- node == 3 ? x.Child2DnaId == Guid.Parse(nodeId) :
- node == 2 ? x.Child1DnaId == Guid.Parse(nodeId) :
- node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId) :
- node == null ? true : true
- ).ToList();
- }
- else if (role == "ROOT")
- {
- data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- // กรองตามที่ fe ส่งมา
- if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "BROTHER" || role == "PARENT")
- {
- data = data
- .Where(x => nodeByReq == 4 ? x.Child4DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 3 ? x.Child3DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 2 ? x.Child2DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 1 ? x.Child1DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 0 ? x.RootDnaId == Guid.Parse(nodeIdByReq) : true)
- .ToList();
- }
- // รายงานการลางานจำแนกตามเพศฯ Template ให้หน่วยงานแสดงก่อนส่วนราชการ
- var org = _userProfileRepository.GetOc(Guid.Parse(nodeIdByReq), nodeByReq ?? 0, AccessToken);
- var organizationName = $"{org.Root ?? ""}{(!string.IsNullOrEmpty(org.Child1) ? "/" + org.Child1 : "")}{(!string.IsNullOrEmpty(org.Child2) ? "/" + org.Child2 : "")}{(!string.IsNullOrEmpty(org.Child3) ? "/" + org.Child3 : "")}{(!string.IsNullOrEmpty(org.Child4) ? "/" + org.Child4 : "")}";
- if (data.Count > 0)
- {
- var grouped = data.GroupBy(d => nodeByReq switch
- {
- 0 => d.Root,
- 1 => d.Child1,
- 2 => d.Child2,
- 3 => d.Child3,
- 4 => d.Child4,
- _ => d.Root
- });
- var res = (/*from d in data
- group d by new { d.Root, d.Child1, d.Child2, d.Child3, d.Child4 } into grp
- orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4*/
- from grp in grouped
- orderby grp.Key
- select new GetSumApproveLeaveByRootDto
- {
- //Root = $"{grp.Key.Root}{(!string.IsNullOrEmpty(grp.Key.Child1) ? "/" + grp.Key.Child1 : "")}{(!string.IsNullOrEmpty(grp.Key.Child2) ? "/" + grp.Key.Child2 : "")}{(!string.IsNullOrEmpty(grp.Key.Child3) ? "/" + grp.Key.Child3 : "")}{(!string.IsNullOrEmpty(grp.Key.Child4) ? "/" + grp.Key.Child4 : "")}",
- Root = organizationName,
- SumLeaveDay = grp.Sum(x => x.LeaveTotal),
- sickDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
- personalDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
- maternityDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
- wifeDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
- restDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
- ordainDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
- absentDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
- studyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
- agencyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
- coupleDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
- therapyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
-
- sickDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
- personalDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
- maternityDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
- wifeDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
- restDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
- ordainDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
- absentDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
- studyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
- agencyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
- coupleDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
- therapyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
-
- sickDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
- personalDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
- maternityDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
- wifeDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
- restDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
- ordainDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
- absentDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
- studyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
- agencyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
- coupleDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
- therapyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
- })
- .ToList();
-
- return res;
+ data = await _dbContext.Set().AsQueryable()
+ .Include(x => x.Type)
+ .Where(x => x.ProfileType == type.Trim().ToUpper())
+ .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
+ .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
}
else
{
- return new List
- {
- new GetSumApproveLeaveByRootDto
- {
- Root = organizationName,
- SumLeaveDay = 0,
- sickDayCountMale = 0,
- maternityDayCountMale = 0,
- wifeDayCountMale = 0,
- personalDayCountMale = 0,
- restDayCountMale = 0,
- ordainDayCountMale = 0,
- absentDayCountMale = 0,
- studyDayCountMale = 0,
- agencyDayCountMale = 0,
- coupleDayCountMale = 0,
- therapyDayCountMale = 0,
- sickDayCountFemale = 0,
- maternityDayCountFemale = 0,
- wifeDayCountFemale = 0,
- personalDayCountFemale = 0,
- restDayCountFemale = 0,
- ordainDayCountFemale = 0,
- absentDayCountFemale = 0,
- studyDayCountFemale = 0,
- agencyDayCountFemale = 0,
- coupleDayCountFemale = 0,
- therapyDayCountFemale = 0,
- sickDayCountNo = 0,
- maternityDayCountNo = 0,
- wifeDayCountNo = 0,
- personalDayCountNo = 0,
- restDayCountNo = 0,
- ordainDayCountNo = 0,
- absentDayCountNo = 0,
- studyDayCountNo = 0,
- agencyDayCountNo = 0,
- coupleDayCountNo = 0,
- therapyDayCountNo = 0
- }
- };
+ data = await _dbContext.Set().AsQueryable()
+ .Include(x => x.Type)
+ .Where(x => x.ProfileType == type.Trim().ToUpper())
+ .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
+ .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
+ .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
+ .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
}
+
+ var res = (from d in data
+ group d by new { d.Root, d.Child1, d.Child2, d.Child3, d.Child4 } into grp
+ orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4
+ select new GetSumApproveLeaveByRootDto
+ {
+ Root = $"{grp.Key.Root}{(!string.IsNullOrEmpty(grp.Key.Child1) ? "/" + grp.Key.Child1 : "")}{(!string.IsNullOrEmpty(grp.Key.Child2) ? "/" + grp.Key.Child2 : "")}{(!string.IsNullOrEmpty(grp.Key.Child3) ? "/" + grp.Key.Child3 : "")}{(!string.IsNullOrEmpty(grp.Key.Child4) ? "/" + grp.Key.Child4 : "")}",
+ SumLeaveDay = grp.Sum(x => x.LeaveTotal),
+ sickDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
+ maternityDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
+ wifeDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
+ personalDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
+ restDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
+ ordainDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
+ absentDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
+ studyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
+ agencyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
+ coupleDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
+ therapyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
+
+ sickDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
+ maternityDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
+ wifeDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
+ personalDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
+ restDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
+ ordainDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
+ absentDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
+ studyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
+ agencyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
+ coupleDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
+ therapyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
+
+ sickDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
+ maternityDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
+ wifeDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
+ personalDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
+ restDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
+ ordainDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
+ absentDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
+ studyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
+ agencyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
+ coupleDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
+ therapyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
+ })
+ .ToList();
+
+ return res;
}
public async Task> GetCountApproveLeaveByTypeAndRange(DateTime startDate, DateTime endDate)
@@ -1998,7 +1561,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
- //.Where(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync();
@@ -2009,139 +1571,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return 0;
}
- public async Task GetSumApproveLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
- {
- // startDate/endDate คือขอบเขตปีงบประมาณ (fiscalStart/fiscalEnd) ที่ caller ส่งมา
- // ใช้ LeaveStartDate เป็นหลักในการ filter เพื่อให้กรณียื่นลาล่วงหน้าข้ามปีงบประมาณ
- // ถูกนับในปีงบประมาณของวันลาจริง (ไม่ใช้วันที่ยื่นลา)
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- .ToListAsync();
-
- if (data.Count > 0)
- return data.Sum(x => x.LeaveTotal);
- else
- return 0;
- }
-
- public async Task GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- .ToListAsync();
-
- if (data.Count > 0)
- return data.Sum(x => x.LeaveTotal);
- else
- return 0;
- }
-
- public async Task GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.ProfileId == profileId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- .ToListAsync();
-
- if (data.Count > 0)
- return data.Sum(x => x.LeaveTotal);
- else
- return 0;
- }
-
- public async Task GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.ProfileId == profileId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- .ToListAsync();
-
- return data.Count;
- }
-
- public async Task GetSumApproveLeaveCountByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
- .ToListAsync();
-
- return data.Count;
- }
-
- ///
- /// วันลาที่สร้างแบบร่างยังไม่ได้ยื่น
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task GetSumDraftLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => x.LeaveStatus == "DRAFT")
- .ToListAsync();
-
- if (data.Count > 0)
- return data.Sum(x => x.LeaveTotal);
- else
- return 0;
- }
-
- ///
- /// วันลาที่ยื่นแล้วรอพิจารณา
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task GetSumNewLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
- {
- var data = await _dbContext.Set().AsQueryable().AsNoTracking()
- .Include(x => x.Type)
- .Where(x => x.KeycloakUserId == keycloakUserId)
- .Where(x => x.Type.Id == leaveTypeId)
- .Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
- .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- .Where(x => (x.LeaveStatus == "NEW" || x.LeaveStatus == "PENDING"))
- .ToListAsync();
-
- if (data.Count > 0)
- return data.Sum(x => x.LeaveTotal);
- else
- return 0;
- }
-
public async Task GetCountApproveLeaveByTypeAndRangeForUser(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
{
var data = await _dbContext.Set().AsQueryable().AsNoTracking()
@@ -2149,7 +1578,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
- //.Where(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate)
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
.ToListAsync();
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs
index d4bc0ea8..2d6f0fcf 100644
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs
@@ -9,8 +9,6 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-using Serilog;
-using System.Diagnostics;
namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
{
@@ -74,8 +72,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
await base.AddAsync(entity);
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
- // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
- var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken ?? "");
+ var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
// send noti + inbox + mail
@@ -145,147 +142,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
}
}
- public async Task> GetAdditionalCheckRequestsByAdminRole(int year, int month, string role, string nodeId, int? node, string? keyword)
- {
- try
- {
- var data = await _dbContext.Set().AsQueryable()
- .Where(x => (x.CheckDate.Year == year && x.CheckDate.Month == month))
- .OrderByDescending(x => x.CreatedAt.Date)
- .ToListAsync();
-
- if (!string.IsNullOrEmpty(keyword))
- {
- data = data.Where(x =>
- (
- (x.Prefix ?? "") + (x.FirstName ?? "") + " " + (x.LastName ?? "")).Contains(keyword)
- || x.Description.Contains(keyword)
-
- ).ToList();
- }
-
- if (role == "OWNER")
- {
- node = null;
- }
- if (role == "OWNER" || role == "CHILD")
- {
- data = data
- .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))))
- .ToList();
- }
- else if (role == "BROTHER")
- {
- data = data
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))
- .ToList();
- }
- else if (role == "ROOT")
- {
- data = data
- .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) &&
- (x.Child1DnaId == Guid.Empty || x.Child1DnaId == null) :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) &&
- (x.Child2DnaId == Guid.Empty || x.Child2DnaId == null) :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) &&
- (x.Child3DnaId == Guid.Empty || x.Child3DnaId == null) :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) &&
- (x.Child4DnaId == Guid.Empty || x.Child4DnaId == null) :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- return data;
- }
- catch
- {
- throw;
- }
- }
-
- public async Task> GetAdditionalCheckRequestsByAdminRole2(DateTime startDate, DateTime endDate, string role, string nodeId, int? node, string? keyword, string? status)
- {
- try
- {
- var data = await _dbContext.Set().AsQueryable()
- .Where(x => (x.CheckDate.Date >= startDate.Date && x.CheckDate.Date <= endDate.Date))
- .OrderByDescending(x => x.CreatedAt.Date)
- .ToListAsync();
-
- if(!string.IsNullOrEmpty(status))
- data = data.Where(x => x.Status == status).ToList();
-
-
- if (!string.IsNullOrEmpty(keyword))
- {
- data = data.Where(x =>
- (
- (x.Prefix ?? "") + (x.FirstName ?? "") + " " + (x.LastName ?? "")).Contains(keyword)
- || x.Description.Contains(keyword)
-
- ).ToList();
- }
-
- if (role == "OWNER")
- {
- node = null;
- }
- if (role == "OWNER" || role == "CHILD")
- {
- data = data
- .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))))
- .ToList();
- }
- else if (role == "BROTHER")
- {
- data = data
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))
- .ToList();
- }
- else if (role == "ROOT")
- {
- data = data
- .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) &&
- (x.Child1DnaId == Guid.Empty || x.Child1DnaId == null) :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) &&
- (x.Child2DnaId == Guid.Empty || x.Child2DnaId == null) :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) &&
- (x.Child3DnaId == Guid.Empty || x.Child3DnaId == null) :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) &&
- (x.Child4DnaId == Guid.Empty || x.Child4DnaId == null) :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- return data;
- }
- catch
- {
- throw;
- }
- }
-
-
#endregion
}
}
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs
deleted file mode 100644
index 0442f557..00000000
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-using BMA.EHR.Application.Common.Interfaces;
-using BMA.EHR.Domain.Models.Leave.TimeAttendants;
-using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
-
-namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
-{
- public class CheckInJobStatusRepository : GenericLeaveRepository
- {
- #region " Fields "
-
- private readonly ILeaveDbContext _dbContext;
-
- #endregion
-
- #region " Constructor and Destructor "
-
- public CheckInJobStatusRepository(ILeaveDbContext dbContext,
- IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
- {
- _dbContext = dbContext;
- }
-
- #endregion
-
- #region " Methods "
-
- ///
- /// ดึงข้อมูล Job Status จาก TaskId
- ///
- public async Task GetByTaskIdAsync(Guid taskId)
- {
- var data = await _dbContext.Set()
- .Where(x => x.TaskId == taskId)
- .FirstOrDefaultAsync();
-
- return data;
- }
-
- ///
- /// ดึงข้อมูล Job Status จาก UserId และสถานะ
- ///
- public async Task> GetByUserIdAndStatusAsync(Guid userId, string status)
- {
- var data = await _dbContext.Set()
- .Where(x => x.KeycloakUserId == userId && x.Status == status)
- .OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- ///
- /// ดึงข้อมูล Job Status ที่ยัง pending หรือ processing
- ///
- public async Task> GetPendingOrProcessingJobsAsync(Guid userId)
- {
- var data = await _dbContext.Set()
- .Where(x => x.KeycloakUserId == userId &&
- (x.Status == "PENDING" || x.Status == "PROCESSING"))
- //.OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- public async Task> GetPendingOrProcessingJobsByDateAsync(DateTime date)
- {
- var data = await _dbContext.Set()
- .Where(x => x.CreatedDate.Date == date.Date &&
- (x.Status == "PENDING" || x.Status == "PROCESSING"))
- .OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- ///
- /// อัปเดตสถานะเป็น Processing
- ///
- public async Task UpdateToProcessingAsync(Guid taskId)
- {
- var job = await GetByTaskIdAsync(taskId);
- if (job != null)
- {
- job.Status = "PROCESSING";
- job.ProcessingDate = DateTime.Now;
- await UpdateAsync(job);
- }
- return job!;
- }
-
- ///
- /// อัปเดตสถานะเป็น Completed
- ///
- public async Task UpdateToCompletedAsync(Guid taskId, string? additionalData = null)
- {
- var job = await GetByTaskIdAsync(taskId);
- if (job != null)
- {
- job.Status = "COMPLETED";
- job.CompletedDate = DateTime.Now;
- if (!string.IsNullOrEmpty(additionalData))
- {
- job.AdditionalData = additionalData;
- }
- await UpdateAsync(job);
- }
- return job!;
- }
-
- ///
- /// อัปเดตสถานะเป็น Failed
- ///
- public async Task UpdateToFailedAsync(Guid taskId, string errorMessage)
- {
- var job = await GetByTaskIdAsync(taskId);
- if (job != null)
- {
- job.Status = "FAILED";
- job.CompletedDate = DateTime.Now;
- job.ErrorMessage = errorMessage;
- await UpdateAsync(job);
- }
- return job!;
- }
-
-
-
- ///
- /// ดึงข้อมูลงานที่ค้างอยู่ในสถานะ PENDING หรือ PROCESSING เกินเวลาที่กำหนด (นาที)
- ///
- public async Task> GetStalePendingOrProcessingJobsAsync(int timeoutMinutes = 30)
- {
- //var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
- var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
- var staleJobs = await _dbContext.Set()
- .Where(x => (x.Status == "PENDING" || x.Status == "PROCESSING")
- && x.CreatedDate <= cutoffDate)
- .OrderBy(x => x.CreatedDate)
- .ToListAsync();
-
- return staleJobs;
- }
-
- ///
- /// ดึงข้อมูลงานที่ค้างอยู่ในสถานะ PENDING หรือ PROCESSING เกินเวลาที่กำหนด (นาที) ของ user คนใดคนหนึ่ง
- ///
- public async Task> GetStalePendingOrProcessingJobsByUserAsync(Guid userId, int timeoutMinutes = 30)
- {
- var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
- //var cutoffDate = new DateTime(2026, 5, 28, 23, 59, 59);
- var staleJobs = await _dbContext.Set()
- .Where(x => x.KeycloakUserId == userId
- && (x.Status == "PENDING" || x.Status == "PROCESSING")
- && x.CreatedDate < cutoffDate)
- .OrderBy(x => x.CreatedDate)
- .ToListAsync();
-
- return staleJobs;
- }
-
- ///
- /// Mark งานที่ค้างเกินเวลาที่กำหนดเป็น FAILED
- ///
- public async Task MarkStaleJobsAsFailedAsync(int timeoutMinutes = 30)
- {
- var staleJobs = await GetStalePendingOrProcessingJobsAsync(timeoutMinutes);
-
- foreach (var job in staleJobs)
- {
- job.Status = "FAILED";
- job.CompletedDate = DateTime.Now;
- job.ErrorMessage = $"งานค้างในสถานะ {job.Status} เกิน {timeoutMinutes} นาที ระบบทำเครื่องหมายเป็น FAILED อัตโนมัติ";
- }
-
- if (staleJobs.Any())
- {
- _dbContext.Set().UpdateRange(staleJobs);
- await _dbContext.SaveChangesAsync();
- }
-
- return staleJobs.Count;
- }
-
- ///
- /// ล้างข้อมูล Job Status ที่เก่าเกิน X วัน
- ///
- public async Task CleanupOldJobsAsync(int daysOld = 30)
- {
- var cutoffDate = DateTime.Now.AddDays(-daysOld);
- var oldJobs = await _dbContext.Set()
- .Where(x => x.CreatedDate < cutoffDate)
- .ToListAsync();
-
- _dbContext.Set().RemoveRange(oldJobs);
- await _dbContext.SaveChangesAsync();
-
- return oldJobs.Count;
- }
-
- #endregion
- }
-}
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs
index e96c35a9..2db889ac 100644
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs
@@ -61,12 +61,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return await _dbContext.Set().Where(x => x.IsActive).ToListAsync();
}
- public async Task GetDefaultAsync(CancellationToken cancellationToken = default)
+ public async Task GetDefaultAsync()
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
- return await _dbContext.Set().Where(x => x.IsDefault).FirstOrDefaultAsync(combinedCts.Token);
+ return await _dbContext.Set().Where(x => x.IsDefault).FirstOrDefaultAsync();
}
#endregion
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs
deleted file mode 100644
index 50e4fc80..00000000
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs
+++ /dev/null
@@ -1,797 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Text.Json;
-using System.IO;
-using BMA.EHR.Application.Common.Interfaces;
-using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
-using BMA.EHR.Application.Repositories.MetaData;
-using BMA.EHR.Application.Responses.Profiles;
-using BMA.EHR.Domain.Extensions;
-using BMA.EHR.Domain.Models.Leave.TimeAttendants;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-
-namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
-{
- public class LeaveProcessJobStatusRepository: GenericLeaveRepository
- {
- #region " Fields "
-
- private readonly ILeaveDbContext _dbContext;
- private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly UserProfileRepository _userProfileRepository;
- private readonly HolidayRepository _holidayRepository;
- private readonly DutyTimeRepository _dutyTimeRepository;
- private readonly UserDutyTimeRepository _userDutyTimeRepository;
- private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository;
- private readonly LeaveRequestRepository _leaveRequestRepository;
- private readonly IConfiguration _configuration;
- private readonly IWebHostEnvironment _env;
-
- #endregion
-
- #region " Constructor and Destructor "
-
- public LeaveProcessJobStatusRepository(ILeaveDbContext dbContext,
- IHttpContextAccessor httpContextAccessor,
- UserProfileRepository userProfileRepository,
- HolidayRepository holidayRepository,
- DutyTimeRepository dutyTimeRepository,
- UserDutyTimeRepository userDutyTimeRepository,
- ProcessUserTimeStampRepository processUserTimeStampRepository,
- LeaveRequestRepository leaveRequestRepository,
- IConfiguration configuration,
- IWebHostEnvironment env) : base(dbContext, httpContextAccessor)
- {
- _dbContext = dbContext;
- _httpContextAccessor = httpContextAccessor;
- _userProfileRepository = userProfileRepository;
- _holidayRepository = holidayRepository;
- _configuration = configuration;
- _leaveRequestRepository = leaveRequestRepository;
- _dutyTimeRepository = dutyTimeRepository;
- _userDutyTimeRepository = userDutyTimeRepository;
- _processUserTimeStampRepository = processUserTimeStampRepository;
- _env = env;
- }
-
- #endregion
-
- #region " Methods "
-
- ///
- /// ดึงข้อมูล Job Status จาก TaskId
- ///
- public async Task GetByTaskIdAsync(Guid id)
- {
- var data = await _dbContext.Set()
- .Where(x => x.Id == id)
- .FirstOrDefaultAsync();
-
- return data;
- }
-
- ///
- /// ดึงข้อมูล Job Status จาก UserId และสถานะ
- ///
- public async Task> GetByUserIdAndStatusAsync(Guid userId, string status)
- {
- var data = await _dbContext.Set()
- .Where(x => x.CreatedUserId == userId.ToString("D") && x.Status == status)
- .OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- ///
- /// ดึงข้อมูล Job Status จาก UserId
- ///
- public async Task> GetByUserIdAsync(Guid userId)
- {
- var data = await _dbContext.Set()
- .Where(x => x.CreatedUserId == userId.ToString("D"))
- .OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- ///
- /// ดึงข้อมูล Job Status ที่ยัง pending หรือ processing
- ///
- public async Task> GetPendingOrProcessingJobsAsync(Guid userId)
- {
- var data = await _dbContext.Set()
- .Where(x => x.CreatedUserId == userId.ToString("D") &&
- (x.Status == "PENDING" || x.Status == "PROCESSING"))
- //.OrderByDescending(x => x.CreatedDate)
- .ToListAsync();
-
- return data;
- }
-
- public async Task> GetPendingJobsAsync()
- {
- var data = await _dbContext.Set()
- .Where(x => x.Status == "PENDING")
- .ToListAsync();
-
- return data;
- }
-
-
-
- ///
- /// อัปเดตสถานะเป็น Processing
- ///
- public async Task UpdateToProcessingAsync(Guid id)
- {
- var job = await GetByTaskIdAsync(id);
- if (job != null)
- {
- job.Status = "PROCESSING";
- job.ProcessingDate = DateTime.Now;
- await UpdateAsync(job);
- }
- return job!;
- }
-
- ///
- /// อัปเดตสถานะเป็น Completed
- ///
- public async Task UpdateToCompletedAsync(Guid id, string? additionalData = null)
- {
- var job = await GetByTaskIdAsync(id);
- if (job != null)
- {
- job.Status = "COMPLETED";
- job.CompletedDate = DateTime.Now;
- await UpdateAsync(job);
- }
- return job!;
- }
-
- ///
- /// อัปเดตสถานะเป็น Failed
- ///
- public async Task UpdateToFailedAsync(Guid id, string errorMessage)
- {
- var job = await GetByTaskIdAsync(id);
- if (job != null)
- {
- job.Status = "FAILED";
- job.CompletedDate = DateTime.Now;
- job.ErrorMessage = errorMessage;
- await UpdateAsync(job);
- }
- return job!;
- }
-
- public async Task ProcessTaskAsync(Guid rootDnaId, DateTime? startDate, DateTime? endDate)
- {
-
- var profiles = new List();
- var dateStart = startDate?.Date ?? DateTime.Now.Date;
- var dateEnd = endDate?.Date ?? DateTime.Now.Date;
-
- var holidays = await _holidayRepository.GetHolidayAsync(dateStart, dateEnd);
- var weekend = _holidayRepository.GetWeekEnd(dateStart, dateEnd);
- var excludeDates = holidays.Union(weekend).ToList();
-
- var dateList = new List();
- for (DateTime i = dateStart; i <= dateEnd; i = i.AddDays(1))
- {
- if (holidays.Contains(i))
- {
- var d = await _holidayRepository.GetHolidayAsync(i);
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = true,
- isWeekEnd = false,
- dateRemark = d
- });
- }
- else if (weekend.Contains(i))
- {
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = true,
- isWeekEnd = false,
- dateRemark = "วันหยุด"
- });
- }
- else
- {
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = false,
- isWeekEnd = false,
- dateRemark = ""
- });
- }
- }
-
- var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
- if (defaultRound == null)
- {
- throw new Exception("ไม่พบรอบการลงเวลา Default");
- }
-
- var employees = new List();
-
- foreach (var dd in dateList.Where(x => !x.isHoliday && !x.isWeekEnd))
- {
- profiles = await _userProfileRepository.GetAllOfficerByRootDnaId(rootDnaId.ToString(),dd.date);
- foreach (var p in profiles)
- {
- var count = 1;
- var keycloakUserId = p.Keycloak ?? Guid.Empty;
-
- var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd.date);
-
- var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";
-
- var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date);
- var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
- var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
-
- var duty = userRound ?? defaultRound;
-
- // check วันลาของแต่ละคน
- var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd.date);
- var remarkStr = string.Empty;
- var status = string.Empty;
- var stampType = string.Empty;
- var stampAmount = 0.0;
-
- if (leaveReq != null)
- {
- switch (leaveReq.Type.Code.ToUpper())
- {
- case "LV-001":
- case "LV-002":
- case "LV-005":
- remarkStr += leaveReq.Type.Name;
- var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper();
-
- if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date)
- {
- if (leaveRange == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRange == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
-
-
- // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- // if (leaveRangeEnd == "MORNING")
- // remarkStr += "ครึ่งวันเช้า";
- // else if (leaveRangeEnd == "AFTERNOON")
- // remarkStr += "ครึ่งวันบ่าย";
-
- var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- if (leaveRange != leaveRangeEnd)
- {
- if (leaveRangeEnd == "MORNING")
- remarkStr += " - ครึ่งวันเช้า";
- else if (leaveRangeEnd == "AFTERNOON")
- remarkStr += " - ครึ่งวันบ่าย";
- }
- }
- else
- {
- if(dd.date == leaveReq.LeaveStartDate.Date)
- {
- if (leaveRange == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRange == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
- }
- else if(dd.date == leaveReq.LeaveEndDate.Date)
- {
- var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- if (leaveRangeEnd == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRangeEnd == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
- else
- remarkStr += "เต็มวัน";
- }
- else
- {
- remarkStr += "เต็มวัน";
- }
- }
-
-
- break;
- default:
- remarkStr += leaveReq.Type.Name;
- break;
- }
- status = "LEAVE";
- if(leaveReq.LeaveStartDate.Date == dd.date)
- {
- stampType = leaveReq.LeaveRange ?? "";
- stampAmount = leaveReq.LeaveRange != "ALL" ? 0.5 : 1;
- }
- else if(leaveReq.LeaveEndDate.Date == dd.date)
- {
- stampAmount = leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1;
- stampType = leaveReq.LeaveRangeEnd ?? "";
- }
- else
- stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1;
- if(stampType == "ALL") stampType = "FULL_DAY";
- }
- else
- {
- if (timeStamps == null)
- {
- if (dd.date <= DateTime.Now.Date)
- {
- remarkStr = "ขาดราชการ";
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- if (dd.isHoliday == true)
- {
- remarkStr = $"วันหยุด ({dd.dateRemark})";
- status = "HOLIDAY";
- }
- else if (dd.isWeekEnd)
- {
- remarkStr = dd.dateRemark;
- status = "WEEKEND";
- }
- }
- else remarkStr = "";
- }
- else
- {
- // check status ของการลงเวลา
- if (timeStamps.CheckOut != null)
- {
- if (timeStamps.CheckOutStatus == "ABSENT")
- {
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckOut ? $" (นอกสถานที่:{timeStamps.CheckOutLocationName})".Trim() : "");
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- }
- else if (timeStamps.CheckInStatus == "ABSENT")
- {
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- }
- else if (timeStamps.CheckInStatus == "LATE")
- {
- remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- status = "LATE";
- stampType = "FULL_DAY";
- stampAmount = 1;
- //lateTotal += 1;
- }
- else
- remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
- }
- else
- {
- if (timeStamps.CheckInStatus == "ABSENT")
- {
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- }
- else if (timeStamps.CheckInStatus == "LATE")
- {
- status = "LATE";
- stampType = "FULL_DAY";
- stampAmount = 1;
- remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- //lateTotal += 1;
- }
- else
- remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
- }
- }
- }
-
- var emp = new DateResultReport
- {
- profileId = p.Id.ToString(),
- stampDate = dd.date,
- stampType = stampType,
- stampAmount = stampAmount,
- remark = remarkStr,
- status = status
- };
-
- employees.Add(emp);
- count++;
- }
-
- // Write employees to JSON file
- // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt";
- // var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Exports", fileName);
-
- // // Ensure directory exists
- // var directory = Path.GetDirectoryName(filePath);
- // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
- // {
- // Directory.CreateDirectory(directory);
- // }
-
- // var jsonOptions = new JsonSerializerOptions
- // {
- // WriteIndented = true,
- // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
- // };
-
- // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions);
- // await File.WriteAllTextAsync(filePath, jsonContent);
- }
-
- //call api
- var apiPath = $"{_configuration["API"]}/org/unauthorize/profile/absent-late/batch";
- var apiKey = _configuration["API_KEY"];
- var body = new
- {
- records = employees.Where(x => x.status == "ABSENT" || x.status == "LATE").ToList()
- };
-
- var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey);
- if(apiResult == "")
- {
- throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ");
- }
- }
-
- public async Task ProcessEmpTaskAsync(Guid rootDnaId, DateTime? startDate, DateTime? endDate)
- {
-
- var profiles = new List();
- var dateStart = startDate?.Date ?? DateTime.Now.Date;
- var dateEnd = endDate?.Date ?? DateTime.Now.Date;
-
- var holidays = await _holidayRepository.GetHolidayAsync(dateStart, dateEnd);
- var weekend = _holidayRepository.GetWeekEnd(dateStart, dateEnd);
- var excludeDates = holidays.Union(weekend).ToList();
-
- var dateList = new List();
- for (DateTime i = dateStart; i <= dateEnd; i = i.AddDays(1))
- {
- if (holidays.Contains(i))
- {
- var d = await _holidayRepository.GetHolidayAsync(i);
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = true,
- isWeekEnd = false,
- dateRemark = d
- });
- }
- else if (weekend.Contains(i))
- {
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = true,
- isWeekEnd = false,
- dateRemark = "วันหยุด"
- });
- }
- else
- {
- dateList.Add(new LoopDate
- {
- date = i,
- isHoliday = false,
- isWeekEnd = false,
- dateRemark = ""
- });
- }
- }
-
- var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
- if (defaultRound == null)
- {
- throw new Exception("ไม่พบรอบการลงเวลา Default");
- }
-
- var employees = new List();
-
- foreach (var dd in dateList.Where(x => !x.isHoliday && !x.isWeekEnd))
- {
- profiles = await _userProfileRepository.GetAllEmployeeByRootDnaId(rootDnaId.ToString(),dd.date);
- foreach (var p in profiles)
- {
- var count = 1;
- var keycloakUserId = p.Keycloak ?? Guid.Empty;
-
- var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd.date);
-
- var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";
-
- var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date);
- var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
- var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
-
- var duty = userRound ?? defaultRound;
-
- // check วันลาของแต่ละคน
- var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd.date);
- var remarkStr = string.Empty;
- var status = string.Empty;
- var stampType = string.Empty;
- var stampAmount = 0.0;
-
- if (leaveReq != null)
- {
- switch (leaveReq.Type.Code.ToUpper())
- {
- case "LV-001":
- case "LV-002":
- case "LV-005":
- remarkStr += leaveReq.Type.Name;
- var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper();
-
- if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date)
- {
- if (leaveRange == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRange == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
-
-
- // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- // if (leaveRangeEnd == "MORNING")
- // remarkStr += "ครึ่งวันเช้า";
- // else if (leaveRangeEnd == "AFTERNOON")
- // remarkStr += "ครึ่งวันบ่าย";
-
- var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- if (leaveRange != leaveRangeEnd)
- {
- if (leaveRangeEnd == "MORNING")
- remarkStr += " - ครึ่งวันเช้า";
- else if (leaveRangeEnd == "AFTERNOON")
- remarkStr += " - ครึ่งวันบ่าย";
- }
- }
- else
- {
- if(dd.date == leaveReq.LeaveStartDate.Date)
- {
- if (leaveRange == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRange == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
- }
- else if(dd.date == leaveReq.LeaveEndDate.Date)
- {
- var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
- if (leaveRangeEnd == "MORNING")
- remarkStr += "ครึ่งวันเช้า";
- else if (leaveRangeEnd == "AFTERNOON")
- remarkStr += "ครึ่งวันบ่าย";
- }
- else
- {
- remarkStr += "เต็มวัน";
- }
- }
- break;
- default:
- remarkStr += leaveReq.Type.Name;
- break;
- }
- status = "LEAVE";
- if(leaveReq.LeaveStartDate.Date == dd.date)
- {
- stampType = leaveReq.LeaveRange ?? "";
- stampAmount = leaveReq.LeaveRange != "ALL" ? 0.5 : 1;
- }
- else if(leaveReq.LeaveEndDate.Date == dd.date)
- {
- stampAmount = leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1;
- stampType = leaveReq.LeaveRangeEnd ?? "";
- }
- else
- stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1;
- if(stampType == "ALL") stampType = "FULL_DAY";
- //stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1;
- }
- else
- {
- if (timeStamps == null)
- {
- if (dd.date <= DateTime.Now.Date)
- {
- remarkStr = "ขาดราชการ";
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- if (dd.isHoliday == true)
- {
- remarkStr = $"วันหยุด ({dd.dateRemark})";
- status = "HOLIDAY";
- }
- else if (dd.isWeekEnd)
- {
- remarkStr = dd.dateRemark;
- status = "WEEKEND";
- }
- }
- else remarkStr = "";
- }
- else
- {
- // check status ของการลงเวลา
- if (timeStamps.CheckOut != null)
- {
- if (timeStamps.CheckOutStatus == "ABSENT")
- {
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckOut ? $" (นอกสถานที่:{timeStamps.CheckOutLocationName})".Trim() : "");
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- }
- else if (timeStamps.CheckInStatus == "ABSENT")
- {
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- }
- else if (timeStamps.CheckInStatus == "LATE")
- {
- remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- status = "LATE";
- stampType = "FULL_DAY";
- stampAmount = 1;
- //lateTotal += 1;
- }
- else
- remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
- }
- else
- {
- if (timeStamps.CheckInStatus == "ABSENT")
- {
- status = "ABSENT";
- stampType = "FULL_DAY";
- stampAmount = 1;
- remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- }
- else if (timeStamps.CheckInStatus == "LATE")
- {
- status = "LATE";
- stampType = "FULL_DAY";
- stampAmount = 1;
- remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : "");
- //lateTotal += 1;
- }
- else
- remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
- }
- }
- }
-
- var emp = new DateResultReport
- {
- profileId = p.Id.ToString(),
- stampDate = dd.date,
- stampType = stampType,
- stampAmount = stampAmount,
- remark = remarkStr,
- status = status
- };
-
- employees.Add(emp);
- count++;
- }
-
- // Write employees to JSON file
- // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt";
- // var filePath = Path.Combine(_env.ContentRootPath, "Exports", fileName);
-
- // // Ensure directory exists
- // var directory = Path.GetDirectoryName(filePath);
- // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
- // {
- // Directory.CreateDirectory(directory);
- // }
-
- // var jsonOptions = new JsonSerializerOptions
- // {
- // WriteIndented = true,
- // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
- // };
-
- // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions);
- // Console.WriteLine($"Writing file to: {filePath}");
- // await File.WriteAllTextAsync(filePath, jsonContent);
- // Console.WriteLine($"File written successfully: {fileName}");
- }
-
- // call api
- var apiPath = $"{_configuration["API"]}/org/unauthorize/profile-employee/absent-late/batch";
- var apiKey = _configuration["API_KEY"];
- var body = new
- {
- records = employees.Where(x => x.status == "ABSENT" || x.status == "LATE").ToList()
- };
-
- var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey);
- if(apiResult == "")
- {
- throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ");
- }
- }
-
-
- public async Task ProcessPendingJobsAsync()
- {
- var pendingJobs = await GetPendingJobsAsync();
- Console.WriteLine($"พบงานที่ค้างอยู่ในสถานะ PENDING จำนวน {pendingJobs.Count} งาน");
-
- foreach (var job in pendingJobs)
- {
- try
- {
- // อัปเดตสถานะเป็น Processing
- await UpdateToProcessingAsync(job.Id);
-
- // ทำงานที่ต้องการที่นี่ (เช่น เรียก API, ประมวลผลข้อมูล ฯลฯ)
- await ProcessTaskAsync(job.RootDnaId,job.StartDate, job.EndDate);
- await ProcessEmpTaskAsync(job.RootDnaId,job.StartDate, job.EndDate);
-
- // อัปเดตสถานะเป็น Completed
- await UpdateToCompletedAsync(job.Id);
- }
- catch (Exception ex)
- {
- // หากเกิดข้อผิดพลาด อัปเดตสถานะเป็น Failed พร้อมข้อความแสดงข้อผิดพลาด
- await UpdateToFailedAsync(job.Id, ex.Message);
- }
- }
- }
-
- #endregion
- }
-
- class LoopDate
- {
- public DateTime date { get; set; }
-
- public bool isHoliday { get; set; }
-
- public bool isWeekEnd { get; set; }
-
- public string dateRemark { get; set; }
-
- }
-
- class DateResultReport
- {
- public string? profileId { get; set; }
- public DateTime stampDate { get; set; }
- public string stampType { get; set; }
- public double stampAmount { get; set; }
- public string remark { get; set; }
- public string status { get; set; }
- }
-
-}
\ No newline at end of file
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs
index 77aba421..17d07e75 100644
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs
@@ -139,64 +139,28 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
- public async Task> GetTimestampByDateLateAsync(string type, string role, string nodeId, int? node, string nodeIdByReq, int? nodeByReq, DateTime StartDate, DateTime EndDate)
+ public async Task> GetTimestampByDateLateAsync(string type, string role, string nodeId, int node, DateTime StartDate, DateTime EndDate)
{
+ var _nodeId = Guid.Parse(nodeId);
var data = new List();
- data = await _dbContext.Set().AsQueryable()
- .Where(x => x.CheckInStatus == "LATE")
- .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
- .Where(x => x.ProfileType == type.Trim().ToUpper()).ToListAsync();
- // กรองตามสิทธิ์ admin ก่อน
- if (role == "CHILD")
+ if (role == "OWNER" || role == "CHILD")
{
- data = data.Where(x =>
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId) :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId) :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId) :
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId) :
- node == null ? true : true
- ).ToList();
+ data = await _dbContext.Set().AsQueryable()
+ .Where(x => x.CheckInStatus == "LATE")
+ .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
+ .Where(x => x.ProfileType == type.Trim().ToUpper())
+ .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
+ .ToListAsync();
}
- else if (role == "BROTHER")
+ else
{
- data = data.Where(x =>
- node == 4 ? x.Child3DnaId == Guid.Parse(nodeId) :
- node == 3 ? x.Child2DnaId == Guid.Parse(nodeId) :
- node == 2 ? x.Child1DnaId == Guid.Parse(nodeId) :
- node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId) :
- node == null ? true : true
- ).ToList();
- }
- else if (role == "ROOT")
- {
- data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- // กรองตามที่ fe ส่งมา
- if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "BROTHER" || role == "PARENT")
- {
- data = data.Where(x =>
- nodeByReq == 4 ? x.Child4DnaId == Guid.Parse(nodeIdByReq) :
- nodeByReq == 3 ? x.Child3DnaId == Guid.Parse(nodeIdByReq) :
- nodeByReq == 2 ? x.Child2DnaId == Guid.Parse(nodeIdByReq) :
- nodeByReq == 1 ? x.Child1DnaId == Guid.Parse(nodeIdByReq) :
- nodeByReq == 0 ? x.RootDnaId == Guid.Parse(nodeIdByReq) : true
- ).ToList();
+ data = await _dbContext.Set().AsQueryable()
+ .Where(x => x.CheckInStatus == "LATE")
+ .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
+ .Where(x => x.ProfileType == type.Trim().ToUpper())
+ .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
+ .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
+ .ToListAsync();
}
return data;
}
@@ -213,12 +177,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
public async Task> GetTimeStampHistoryAsync(Guid keycloakId, int year, int page = 1, int pageSize = 10, string keyword = "")
{
- var fiscalDateStart = new DateTime(year - 1, 10, 1);
- var fiscalDateEnd = new DateTime(year, 9, 30);
-
var data = await _dbContext.Set()
.Where(u => u.KeycloakUserId == keycloakId)
- .Where(u => u.CheckIn.Date >= fiscalDateStart && u.CheckIn.Date <= fiscalDateEnd)
+ .Where(u => u.CheckIn.Year == year)
.OrderByDescending(u => u.CheckIn.Date)
.Skip((page - 1) * pageSize)
.Take(pageSize)
@@ -227,19 +188,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
- public async Task> GetTimeStampHistoryAsync2(Guid keycloakId, int year)
- {
- var fiscalDateStart = new DateTime(year - 1, 10, 1);
- var fiscalDateEnd = new DateTime(year, 9, 30);
-
- var data = await _dbContext.Set()
- .Where(u => u.KeycloakUserId == keycloakId)
- .Where(u => u.CheckIn.Date >= fiscalDateStart && u.CheckIn.Date <= fiscalDateEnd)
- .OrderByDescending(u => u.CheckIn.Date)
- .ToListAsync();
- return data;
- }
-
public async Task GetTimeStampHistoryForAdminCountAsync(DateTime startDate, DateTime endDate)
{
var data = await _dbContext.Set()
@@ -272,55 +220,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
- public async Task> GetTimeStampHistoryForAdminRoleAsync(DateTime startDate, DateTime endDate, string role, string nodeId, int? node)
- {
- var data = await _dbContext.Set()
- .Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
- .OrderBy(u => u.CheckIn)
-
- .ToListAsync();
- if (role == "OWNER")
- {
- node = null;
- }
- if (role == "OWNER" || role == "CHILD")
- {
- data = data
- .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))))
- .ToList();
- }
- else if (role == "BROTHER")
- {
- data = data
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))
- .ToList();
- }
- else if (role == "ROOT")
- {
- data = data
- .Where(x => x.RootDnaId == Guid.Parse(nodeId!))
- .ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null)
- // .ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- return data;
- }
-
public async Task GetTimeStampById(Guid id)
{
var data = await _dbContext.Set()
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs
index b34bc4db..3eefefe0 100644
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs
@@ -101,17 +101,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
- public async Task GetLastEffectRound(Guid profileId, DateTime? effectiveDate = null, CancellationToken cancellationToken = default)
+ public async Task GetLastEffectRound(Guid profileId)
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
- effectiveDate ??= DateTime.Now;
var data = await _dbContext.Set()
.Where(x => x.ProfileId == profileId)
- .Where(x => x.EffectiveDate.Value.Date <= effectiveDate.Value.Date)
+ .Where(x => x.IsProcess)
+ .Where(x => x.EffectiveDate.Value.Date <= DateTime.Now.Date)
.OrderByDescending(x => x.EffectiveDate)
- .FirstOrDefaultAsync(combinedCts.Token);
+ .FirstOrDefaultAsync();
return data;
}
diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs
index 6dffcb6c..2eb6f6b3 100644
--- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs
+++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs
@@ -74,16 +74,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
- public async Task GetLastRecord(Guid keycloakId, CancellationToken cancellationToken = default)
+ public async Task GetLastRecord(Guid keycloakId)
{
- // กำหนด timeout เป็น 30 นาที
- using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30));
- using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);
-
var data = await _dbContext.Set()
.Where(u => u.KeycloakUserId == keycloakId)
.OrderByDescending(u => u.CheckIn)
- .FirstOrDefaultAsync(combinedCts.Token);
+ .FirstOrDefaultAsync();
return data;
}
@@ -94,7 +90,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
.Where(u => u.KeycloakUserId == keycloakId)
.Where(u => u.CheckIn.Year == year)
.OrderBy(u => u.CheckIn)
-
+
.ToListAsync();
return data;
@@ -105,61 +101,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
var data = await _dbContext.Set()
.Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
.OrderBy(u => u.CheckIn)
-
+
.ToListAsync();
return data;
}
- public async Task> GetTimeStampHistoryForAdminRoleAsync(DateTime startDate, DateTime endDate, string role, string nodeId, int? node)
- {
- var data = await _dbContext.Set()
- .Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
- .OrderBy(u => u.CheckIn)
-
- .ToListAsync();
- if (role == "OWNER")
- {
- node = null;
- }
- if (role == "OWNER" || role == "CHILD")
- {
- data = data
- .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))))
- .ToList();
- }
- else if (role == "BROTHER")
- {
- data = data
- .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))
- .ToList();
- }
- else if (role == "ROOT")
- {
- data = data
- .Where(x => x.RootDnaId == Guid.Parse(nodeId!))
- .ToList();
- }
- // else if (role == "PARENT")
- // {
- // data = data
- // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null)
- // .ToList();
- // }
- else if (role == "NORMAL")
- {
- data = data.Where(x =>
- node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId == null :
- node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
- node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
- node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
- node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) :
- true
- ).ToList();
- }
- return data;
- }
-
public async Task GetTimeStampById(Guid id)
{
var data = await _dbContext.Set()
diff --git a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs
index 46019cfc..af44f06b 100644
--- a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs
+++ b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs
@@ -51,13 +51,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// // throw new Exception(GlobalMessages.DataNotFound);
// }
- //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
- var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
+ var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
var profileId = "";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs
index 9a8d71e3..41135a1f 100644
--- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs
+++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs
@@ -55,13 +55,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// // throw new Exception(GlobalMessages.DataNotFound);
// }
- //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
- var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
+ var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
var profileId = "";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -132,13 +131,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// {
// return 0;
// }
- //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
- var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
+ var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
var profileId = "";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -187,44 +185,6 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
}
}
- private async Task GetMyProfileIdAsync()
- {
- var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
- var response = await GetExternalAPIAsync(apiUrl, AccessToken!, _configuration["API_KEY"]!);
-
- if (string.IsNullOrWhiteSpace(response))
- return string.Empty;
-
- var org = JsonConvert.DeserializeObject(response);
- if (org == null || org.result == null)
- return string.Empty;
-
- return org.result.profileId ?? string.Empty;
- }
-
- public async Task DeleteAllMyNotificationsAsync()
- {
- try
- {
- var profileId = await GetMyProfileIdAsync();
- if (string.IsNullOrEmpty(profileId))
- return 0;
-
- var notifications = await _dbContext.Set()
- .Where(x => x.ReceiverUserId == Guid.Parse(profileId))
- .Where(x => x.DeleteDate == null)
- .ToListAsync();
-
- _dbContext.Set().RemoveRange(notifications);
- await _dbContext.SaveChangesAsync();
- return notifications.Count;
- }
- catch
- {
- throw;
- }
- }
-
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", string NotiLink = "", bool IsSendInbox = false, bool IsSendMail = false)
{
try
@@ -267,7 +227,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -327,7 +287,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -401,7 +361,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -474,7 +434,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -544,7 +504,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
@@ -606,7 +566,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
diff --git a/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs b/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs
index 1c8ae006..c5c09a44 100644
--- a/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs
+++ b/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs
@@ -49,16 +49,12 @@ namespace BMA.EHR.Application.Repositories.MetaData
public async Task GetHolidayCountAsync(DateTime startDate, DateTime endDate, string category = "NORMAL")
{
- var query = _dbContext.Set().AsQueryable()
+ var data = await _dbContext.Set().AsQueryable()
.Where(x => x.Category == category)
- .Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate);
+ .Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate)
+ .CountAsync();
- if (category == "NORMAL")
- query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Saturday && x.HolidayDate.DayOfWeek != DayOfWeek.Sunday);
- else
- query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Sunday);
-
- return await query.CountAsync();
+ return data;
}
public List GetWeekEnd(DateTime startDate, DateTime endDate, string category = "NORMAL")
diff --git a/BMA.EHR.Application/Repositories/MinIOService.cs b/BMA.EHR.Application/Repositories/MinIOService.cs
index bf74270f..ea470b27 100644
--- a/BMA.EHR.Application/Repositories/MinIOService.cs
+++ b/BMA.EHR.Application/Repositories/MinIOService.cs
@@ -155,40 +155,6 @@ namespace BMA.EHR.Application.Repositories
}
}
- public async Task GetImageToFormFileAsync(string refId)
- {
- try
- {
- using var memoryStream = new MemoryStream();
- var request = new GetObjectRequest
- {
- BucketName = _bucketName,
- Key = refId
- };
-
- using var response = await _s3Client.GetObjectAsync(request);
- using var responseStream = response.ResponseStream;
-
- await responseStream.CopyToAsync(memoryStream);
-
- var finalBytes = memoryStream.ToArray();
-
- var finalStream = new MemoryStream(finalBytes);
- var fileName = Path.GetFileName(refId);
- var contentType = response.Headers.ContentType ?? "image/jpeg";
-
- return new FormFile(finalStream, 0, finalStream.Length, "file", fileName)
- {
- Headers = new HeaderDictionary(),
- ContentType = contentType
- };
- }
- catch
- {
- throw;
- }
- }
-
public async Task DeleteFileAsync(Guid fileId)
{
try
diff --git a/BMA.EHR.Application/Repositories/PermissionRepository.cs b/BMA.EHR.Application/Repositories/PermissionRepository.cs
index a63207ec..27ee8696 100644
--- a/BMA.EHR.Application/Repositories/PermissionRepository.cs
+++ b/BMA.EHR.Application/Repositories/PermissionRepository.cs
@@ -10,7 +10,6 @@ using System.Net.Http.Headers;
using Microsoft.Extensions.Configuration;
using System.Security.Claims;
using System.Net.Http.Json;
-using BMA.EHR.Application.Responses.Leaves;
namespace BMA.EHR.Application.Repositories
{
@@ -59,14 +58,9 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
- client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = await client.GetAsync(apiPath);
- if (!req.IsSuccessStatusCode)
- {
- throw new Exception("Error calling permission API");
- }
var res = await req.Content.ReadAsStringAsync();
return res;
}
@@ -77,39 +71,6 @@ namespace BMA.EHR.Application.Repositories
}
}
- public async Task GetPermissionWithActingAPIAsync(string action, string system)
- {
- try
- {
- var apiPath = $"{_configuration["API"]}/org/permission/dotnet-acting/{action}/{system}";
-
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
- var req = await client.GetAsync(apiPath);
- if (!req.IsSuccessStatusCode)
- {
- throw new Exception("Error calling permission API");
- }
- var apiResult = await req.Content.ReadAsStringAsync();
- //return res;
-
- if (apiResult != null)
- {
- var raw = JsonConvert.DeserializeObject(apiResult);
- return raw;
- }
- return null;
- }
- }
- catch
- {
- throw;
- }
- }
-
public async Task GetPermissionOrgAPIAsync(string action, string system, string profileId)
{
try
@@ -119,7 +80,7 @@ namespace BMA.EHR.Application.Repositories
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = await client.GetAsync(apiPath);
var res = await req.Content.ReadAsStringAsync();
return res;
diff --git a/BMA.EHR.Application/Repositories/PlacementRepository.cs b/BMA.EHR.Application/Repositories/PlacementRepository.cs
index eb7c3617..49f1175c 100644
--- a/BMA.EHR.Application/Repositories/PlacementRepository.cs
+++ b/BMA.EHR.Application/Repositories/PlacementRepository.cs
@@ -2,40 +2,24 @@
using BMA.EHR.Domain.Models.Placement;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using System.Net.Http.Headers;
-using Newtonsoft.Json;
namespace BMA.EHR.Application.Repositories
{
- ///
- /// Response model จาก Org API (check-isLeave)
- ///
- public class OrgProfileResult
- {
- public string citizenId { get; set; } = "";
- public string? profileId { get; set; }
- public bool isLeave { get; set; }
- public bool isActive { get; set; }
- }
-
public class PlacementRepository : GenericRepository
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly IConfiguration _configuration;
#endregion
#region " Constructor and Destructor "
- public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor, IConfiguration configuration) : base(dbContext, httpContextAccessor)
+ public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
- _configuration = configuration;
}
#endregion
@@ -92,148 +76,6 @@ namespace BMA.EHR.Application.Repositories
return data;
}
- ///
- /// Job อัพเดทสถานะผู้สอบผ่านที่ลาออกไปแล้วแต่ยังไม่ส่งไปออกคำสั่ง
- /// และอัพเดทบุคคลภายนอกที่เข้ามาอยู่ในระบบแล้ว
- /// ทำงานทุกวันเวลา 05:00 น.
- ///
- public async Task UpdateStatusPlacementProfiles()
- {
- Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === STARTED ===");
-
- // 1. Query ทั้ง 2 กรณี: ทุกคนที่ยังไม่ DONE
- var allCitizenIds = await _dbContext.Set()
- .Where(p => !string.IsNullOrEmpty(p.CitizenId)
- && p.PlacementStatus != "DONE"
- // && p.CitizenId == "2536721883131"
- )
- .Select(p => new { p.CitizenId, p.IsOfficer })
- .ToListAsync();
-
- if (!allCitizenIds.Any())
- {
- Console.WriteLine("[Job:UpdateStatusPlacementProfiles] No profiles to process");
- return;
- }
-
- var officerCount = allCitizenIds.Count(x => x.IsOfficer == true);
- var notOfficerCount = allCitizenIds.Count(x => x.IsOfficer == false);
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] พบข้าราชการ {officerCount} คน, บุคคลภายนอก {notOfficerCount} คน");
-
- // 2. ส่ง citizenIds ทั้งหมดไป Org API ครั้งเดียว
- var citizenIds = allCitizenIds.Select(x => x.CitizenId).Distinct().ToList();
- var apiUrl = $"{_configuration["API"]}/org/dotnet/check-isLeave";
-
- List orgResults = new();
-
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
-
- var payload = new { citizenIds };
- var jsonPayload = JsonConvert.SerializeObject(payload);
- var content = new StringContent(jsonPayload, System.Text.Encoding.UTF8, "application/json");
-
- try
- {
- var response = await client.PostAsync(apiUrl, content);
- var result = await response.Content.ReadAsStringAsync();
-
- var responseObj = JsonConvert.DeserializeAnonymousType(result, new
- {
- status = 0,
- message = "",
- result = new List()
- });
-
- orgResults = responseObj?.result ?? new();
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] Org API ตอบกลับ {orgResults.Count} รายการ");
- }
- catch (Exception ex)
- {
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] Call API failed: {ex.Message}");
- return;
- }
- }
-
- if (!orgResults.Any())
- {
- Console.WriteLine("[Job:UpdateStatusPlacementProfiles] ไม่มีรายการต้องอัปเดต");
- Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === COMPLETED ===");
- return;
- }
-
- // 3. แยกข้อมูลตามเงื่อนไข
- var leaveCitizenIds = orgResults.Where(x => x.isLeave).Select(x => x.citizenId).ToList();
- var inSystemProfiles = orgResults.Where(x => x.isActive && !x.isLeave && !string.IsNullOrEmpty(x.profileId)).ToList();
-
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] ลาออก {leaveCitizenIds.Count} รายการ, อยู่ที่ทะเบียนประวัติ {inSystemProfiles.Count} รายการ");
-
- // 4. Split Batch Update (500 รายการ/batch)
- var batchSize = 500;
- var totalUpdated = 0;
-
- // 4.1 Update คนลาออก → IsOfficer = false
- if (leaveCitizenIds.Any())
- {
- var totalBatches = (int)Math.Ceiling((double)leaveCitizenIds.Count / batchSize);
- for (int i = 0; i < totalBatches; i++)
- {
- var batch = leaveCitizenIds.Skip(i * batchSize).Take(batchSize).ToList();
-
- var profilesToUpdate = await _dbContext.Set()
- .Where(p => !string.IsNullOrEmpty(p.CitizenId)
- && batch.Contains(p.CitizenId)
- && p.IsOfficer == true)
- .ToListAsync();
-
- foreach (var profile in profilesToUpdate)
- {
- profile.profileId = null;
- profile.IsOfficer = false;
- }
-
- await _dbContext.SaveChangesAsync();
- totalUpdated += profilesToUpdate.Count;
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] [ลาออก] Batch {i + 1}/{totalBatches} → อัปเดต {profilesToUpdate.Count} รายการ");
- }
- }
-
- // 4.2 Update คนที่อยู่ในทะเบียนประวัติ → profileId + IsOfficer = true
- if (inSystemProfiles.Any())
- {
- var totalBatches = (int)Math.Ceiling((double)inSystemProfiles.Count / batchSize);
- for (int i = 0; i < totalBatches; i++)
- {
- var batch = inSystemProfiles.Skip(i * batchSize).Take(batchSize).ToList();
- var batchCitizenIds = batch.Select(x => x.citizenId).ToList();
-
- var profilesToUpdate = await _dbContext.Set()
- .Where(p => !string.IsNullOrEmpty(p.CitizenId)
- && batchCitizenIds.Contains(p.CitizenId)
- && p.IsOfficer == false)
- .ToListAsync();
-
- foreach (var profile in profilesToUpdate)
- {
- var orgProfile = batch.FirstOrDefault(x => x.citizenId == profile.CitizenId);
- if (orgProfile != null)
- {
- profile.profileId = orgProfile.profileId;
- profile.IsOfficer = true;
- }
- }
-
- await _dbContext.SaveChangesAsync();
- totalUpdated += profilesToUpdate.Count;
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] [เข้าระบบ] Batch {i + 1}/{totalBatches} → อัปเดต {profilesToUpdate.Count} รายการ");
- }
- }
-
- Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] อัปเดตรวมทั้งหมด {totalUpdated} รายการ");
- Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === COMPLETED ===");
- }
-
#endregion
}
}
diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs
index ce460b8d..b6932574 100644
--- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs
+++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs
@@ -5,7 +5,6 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using System.Text;
-using System.Text.RegularExpressions;
using static BMA.EHR.Domain.Extensions.DateTimeExtension;
namespace BMA.EHR.Application.Repositories.Reports
@@ -83,128 +82,76 @@ namespace BMA.EHR.Application.Repositories.Reports
sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน ");
sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน ");
}
- var candidate = await _dbExamContext.Set()
- .Where(x => x.Id == id)
- .Include(p => p.PeriodExam)
- .Include(p => p.Educations)
- .Include(p => p.PositionExam)
- .Include(p => p.ProfileImg)
- .FirstOrDefaultAsync();
+ var data = await _dbExamContext.Set().AsQueryable()
+ .Where(x => x.Id == id)
+ .Select(p => new
+ {
+ p.Id,
+ AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id,
+ ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(),
+ PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName.ToThaiNumber(),
+ PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName.ToThaiNumber(),
+ PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name.ToThaiNumber(),
+ PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString().ToThaiNumber(),
+ PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString().ToThaiNumber(),
- if (candidate == null)
+ FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
+ Religion = p.ReligionName == null ? "-" : p.ReligionName,
+ Nationality = p.Nationality == null ? "-" : p.Nationality,
+ DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2().ToThaiNumber(),
+ Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0).ToThaiNumber(),
+ CitizenId = p.CitizenId == null ? "-" : p.CitizenId.ToThaiNumber(),
+
+ EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName.ToThaiNumber(),
+ EducationName = p.Educations.FirstOrDefault() == null ? null : (p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาตรี" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาโท" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาเอก" ? p.Educations.FirstOrDefault().EducationName : null),
+ EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor.ToThaiNumber(),
+ EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation,
+ EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2().ToThaiNumber(),
+ EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores.ToThaiNumber(),
+ EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType,
+ EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName,
+
+ OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")),
+ OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition,
+ OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.Value.ToString("N0").ToThaiNumber(),
+ OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup,
+ OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile,
+ OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg,
+ OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone.ToThaiNumber(),
+
+ CareersTotal = sb.ToString().ToThaiNumber(),
+ // Careers = p.Careers.Select(y => new
+ // {
+ // Position = y.Position,
+ // Type = y.Type,
+ // DurationStart = y.DurationStart.ToThaiShortDate2(),
+ // DurationEnd = y.DurationEnd.ToThaiShortDate2(),
+ // RangeDate = y.RangeDate,
+ // }).ToList(),
+
+ RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber(),
+ RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName,
+ RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName,
+ RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName,
+ RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber(),
+ CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber()) : p.CurrentAddress.ToThaiNumber(),
+ CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName,
+ CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentDistrictName,
+ CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentSubDistrictName,
+ CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber()) : p.CurrentZipCode.ToThaiNumber(),
+ Telephone = p.Telephone == null ? "-" : p.Telephone.ToThaiNumber(),
+ Email = p.Email == null ? "-" : p.Email,
+
+ ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}",
+ ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations,
+ ContactTel = p.ContactTel == null ? "-" : p.ContactTel.ToThaiNumber(),
+
+ RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate().ToThaiNumber(),
+ })
+ .FirstOrDefaultAsync();
+ if (data == null)
throw new Exception(GlobalMessages.CandidateNotFound);
-
- List editorConfirmLists;
-
- var textOnly = string.IsNullOrEmpty(candidate.PeriodExam?.EditorConfirm)
- ? null
- : Regex.Replace(
- candidate.PeriodExam.EditorConfirm,
- "<[^>]+>",
- string.Empty
- )
- .Replace(" ", " ")
- .Trim();
-
- if (!string.IsNullOrEmpty(textOnly))
- {
- // ลบข้อความทั้งหมดก่อน "1." เพื่อให้เริ่มต้นที่ข้อแรกเสมอ
- var cleanedText = Regex.Replace(textOnly, @"^.*?1\.", "1.").Trim();
-
- // ถ้าข้อ 3 จบด้วย "มาตรา 1374." แล้วเลข 4. ติดกับประโยค ให้แทรกขึ้นบรรทัดใหม่เป็นข้อ 4.
- if (!cleanedText.Contains("\n4.") && Regex.IsMatch(cleanedText, @"1374\.\s*"))
- {
- cleanedText = Regex.Replace(cleanedText, @"1374\.\s*", "137\n4. ");
- }
-
- // แยกข้อความเป็นแต่ละข้อ โดย split เมื่อเจอ pattern "ตัวเลข. "
- // ใช้ lookahead (?=...) เพื่อไม่กินตัวเลขทิ้ง และให้ตัวเลขยังอยู่ในผลลัพธ์
- editorConfirmLists = Regex.Split(cleanedText, @"(?=\d+\. )")
- .Where(s => !string.IsNullOrWhiteSpace(s))
- .Select(s => s.Replace("\n", "").Replace("\r", "").Trim())
- .ToList();
- }
- else
- {
- editorConfirmLists = new List { "-" };
- }
-
- return new
- {
- candidate.Id,
- AvatarId = candidate.ProfileImg?.Id ?? Guid.Empty,
- ExamIdenNumber = candidate.ExamIdenNumber ?? "-",
- PositionName = candidate.PositionExam?.PositionName ?? "-",
- PositionLevelName = candidate.PositionExam?.PositionLevelName ?? "-",
- PeriodExamName = candidate.PeriodExam?.Name ?? "-",
- PeriodExamRound = candidate.PeriodExam?.Round.ToString() ?? "-",
- PeriodExamYear = candidate.PeriodExam != null ? (candidate.PeriodExam.Year + 543).ToString() : "-",
- FullName = $"{candidate.PrefixName}{candidate.FirstName} {candidate.LastName}",
- Religion = candidate.ReligionName ?? "-",
- Nationality = candidate.Nationality ?? "-",
- DateOfBirth = candidate.DateOfBirth?.ToThaiFullDate2() ?? "-",
- Age = candidate.DateOfBirth?.CalculateAgeStrV2(0, 0) ?? "-",
- CitizenId = candidate.CitizenId ?? "-",
-
- EducationLevelExamName = candidate.Educations.FirstOrDefault()?.EducationLevelExamName ?? "-",
- EducationName = (candidate.Educations.FirstOrDefault()?.EducationLevelExamName is "ปริญญาตรี" or "ปริญญาโท" or "ปริญญาเอก")
- ? candidate.Educations.FirstOrDefault()?.EducationName
- : null,
- EducationMajor = candidate.Educations.FirstOrDefault()?.EducationMajor ?? "-",
- EducationLocation = candidate.Educations.FirstOrDefault()?.EducationLocation ?? "-",
- EducationEndDate = candidate.Educations.FirstOrDefault()?.EducationEndDate?.ToThaiFullDate2() ?? "-",
- EducationScores = candidate.Educations.FirstOrDefault()?.EducationScores ?? "-",
- EducationType = candidate.Educations.FirstOrDefault()?.EducationType ?? "-",
- EducationLevelHighName = candidate.Educations.FirstOrDefault()?.EducationLevelHighName ?? "-",
-
- OccupationPositionType = candidate.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" :
- candidate.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" :
- candidate.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-",
- OccupationPosition = candidate.OccupationPosition ?? "-",
- OccupationSalary = candidate.OccupationSalary.HasValue
- ? (candidate.OccupationSalary.Value % 1 == 0
- ? candidate.OccupationSalary.Value.ToString("N0")
- : candidate.OccupationSalary.Value.ToString("N2"))
- : "-",
- OccupationGroup = candidate.OccupationGroup ?? "-",
- OccupationPile = candidate.OccupationPile ?? "-",
- OccupationOrg = candidate.OccupationOrg ?? "-",
- OccupationTelephone = candidate.OccupationTelephone ?? "-",
-
- CareersTotal = sb.ToString(),
-
- RegistAddress = candidate.RegistAddress ?? "-",
- RegistProvinceName = candidate.RegistProvinceName ?? "-",
- RegistDistrictName = candidate.RegistDistrictName ?? "-",
- RegistSubDistrictName = candidate.RegistSubDistrictName ?? "-",
- RegistZipCode = candidate.RegistZipCode ?? "-",
- CurrentAddress = candidate.CurrentAddress ?? candidate.RegistAddress ?? "-",
- CurrentProvinceName = candidate.CurrentProvinceName ?? candidate.RegistProvinceName ?? "-",
- CurrentDistrictName = candidate.CurrentDistrictName ?? candidate.RegistDistrictName ?? "-",
- CurrentSubDistrictName = candidate.CurrentSubDistrictName ?? candidate.RegistSubDistrictName ?? "-",
- CurrentZipCode = candidate.CurrentZipCode ?? candidate.RegistZipCode ?? "-",
- Telephone = candidate.Telephone ?? "-",
- Email = candidate.Email ?? "-",
-
- ContactFullName = $"{candidate.ContactPrefixName}{candidate.ContactFirstname} {candidate.ContactLastname}",
- ContactRelations = candidate.ContactRelations ?? "-",
- ContactTel = candidate.ContactTel ?? "-",
-
- RegisterDate = candidate.RegisterDate?.ToThaiFullDate() ?? "-",
-
- IsBachelors = candidate.PositionExam != null && !string.IsNullOrEmpty(candidate.PositionExam.PositionLevelName) && candidate.PositionExam.PositionLevelName.Trim() == "ปฏิบัติการ"
- ? new List