feat: Use FirstOrDefaultAsync for contract retrieval#209
Conversation
Replaces SingleOrDefaultAsync with FirstOrDefaultAsync when fetching contracts by customer ID. This change prevents exceptions if multiple contracts exist for a customer and returns the most recently prepared contract.
There was a problem hiding this comment.
Pull Request Overview
This PR updates contract retrieval logic to handle scenarios where multiple contracts exist for a single customer. The change replaces SingleOrDefaultAsync with FirstOrDefaultAsync to prevent exceptions and return the most recently prepared contract based on the existing OrderByDescending sort.
- Changes contract query method to use
FirstOrDefaultAsyncinstead ofSingleOrDefaultAsync
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
==========================================
+ Coverage 96.49% 96.55% +0.05%
==========================================
Files 61 62 +1
Lines 542 551 +9
Branches 9 9
==========================================
+ Hits 523 532 +9
Misses 16 16
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replaces SingleOrDefaultAsync with FirstOrDefaultAsync when fetching contracts by customer ID. This change prevents exceptions if multiple contracts exist for a customer and returns the most recently prepared contract.