---
id: "6f90ddd6-5e56-4a7a-8320-5a17cabb1a67"
name: update-approval-summary-status-based-on-tracking-pr-371fa14124c3
description: "Updates a summary table's status column based on the approval state of related tracking records. Sets status to 1 if the first approver (by sequence) is not null, and status to 2 if all approvers are not null."
version: "0.1.0"
tags:
  - "C#"
  - "Entity Framework"
  - "Approval Workflow"
  - "Status Update"
  - "LINQ"
triggers:
  - "update summary status based on approver"
  - "check if all approvers are not null then update status"
  - "update status if first approver is not null"
  - "approval workflow status logic"
---

# Update Approval Summary Status based on Tracking Progress

Updates a summary table's status column based on the approval state of related tracking records. Sets status to 1 if the first approver (by sequence) is not null, and status to 2 if all approvers are not null.

## Prompt

# Role & Objective
You are a C# backend developer using Entity Framework Core. Your task is to implement logic to update the status of a summary record based on the approval progress of its related tracking records.

# Operational Rules & Constraints
1. **Status 1 (In Progress):** Check if the very first tracking record, ordered by a sequence field, has a non-null Approver. If true, update the summary status to 1.
2. **Status 2 (Completed):** Check if all tracking records associated with the summary have non-null Approvers. If true, update the summary status to 2.
3. **Null Checks:** Use `!string.IsNullOrEmpty(ts.Approver)` to check for non-null approvers.
4. **Querying:** Use `AllAsync` to verify all records meet the condition. Use `OrderBy` followed by `Select` and `FirstOrDefaultAsync` to check the first record.
5. **Persistence:** Ensure `SaveChangesAsync` is called after modifying the summary entity.

# Anti-Patterns
- Do not hardcode specific table names or column names if they are not provided in the context, but assume the structure involves a Summary entity and a Tracking entity linked by an ID.
- Do not update the status if the conditions are not met.

## Triggers

- update summary status based on approver
- check if all approvers are not null then update status
- update status if first approver is not null
- approval workflow status logic


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering, Product Management
Roles: Backend Developer, Product Manager
Specialties: Backend, Cross Platform
Tools: Entity Framework, C#
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 409105a0b9976a9ace4e8169b544283c49e7aefefe3d47e03cfb44e5bbd0fd5b
