Email report background service#33
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new background service that generates a daily PDF report of open service orders and emails it to administrators, introducing configuration, interfaces, implementations, and DI registrations.
- Define
ReportSettingsin configuration for report scheduling and email addresses. - Add
IEmailWithAttachmentSenderinterface with SMTP and SendGrid implementations. - Implement
OpenOrdersReportBackgroundServiceto generate PDF via QuestPDF and send emails.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| CarWorkshopManager/appsettings.json | Add ReportSettings block for interval, admin and sender emails |
| CarWorkshopManager/Services/Interfaces/IServiceOrderService.cs | Add GetOpenServiceOrdersAsync to fetch open orders |
| CarWorkshopManager/Services/Interfaces/IEmailWithAttachmentSender.cs | Introduce interface for sending emails with attachments |
| CarWorkshopManager/Services/Implementations/SmtpEmailWithAttachmentSender.cs | Implement SMTP-based email sender; reads ReportSettings:Smtp |
| CarWorkshopManager/Services/Implementations/SendGridEmailWithAttachmentSender.cs | Implement SendGrid-based email sender |
| CarWorkshopManager/Services/Implementations/ServiceOrderService.cs | Provide implementation for fetching open orders |
| CarWorkshopManager/Services/Implementations/OpenOrdersReportBackgroundService.cs | Add background service to generate and email PDF reports |
| CarWorkshopManager/Program.cs | Register email sender and background service with DI container |
| CarWorkshopManager/Documents/DailyReportDocument.cs | Define QuestPDF document classes for open orders report (filename mismatches class name) |
Comments suppressed due to low confidence (6)
CarWorkshopManager/Services/Interfaces/IEmailWithAttachmentSender.cs:13
- [nitpick] The parameter name
attachmentTypeis ambiguous. Consider renaming tocontentTypeormimeTypeto clearly indicate it refers to the attachment's MIME type.
string attachmentType);
CarWorkshopManager/appsettings.json:19
- Sensitive SendGrid API key is checked into source control in appsettings.json. Use user secrets or environment variables to protect credentials.
"ApiKey": "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",
CarWorkshopManager/Services/Implementations/ServiceOrderService.cs:227
- New method
GetOpenServiceOrdersAsyncis not covered by existing tests. Consider adding unit tests to validate its behavior, especially the filtering logic.
public async Task<List<ServiceOrderListItemViewModel>> GetOpenServiceOrdersAsync()
CarWorkshopManager/Services/Implementations/SmtpEmailWithAttachmentSender.cs:28
- Configuration section "ReportSettings:Smtp" does not exist in appsettings.json. You should add Host, Port, Username, Password, and EnableSsl under a "ReportSettings:Smtp" section or adjust the code to match existing settings.
var smtp = _config.GetSection("ReportSettings:Smtp");
CarWorkshopManager/Services/Implementations/SendGridEmailWithAttachmentSender.cs:21
- The code expects a "SendGrid:SenderName" setting, but appsettings.json does not define it. Add SenderName under the SendGrid section or fallback to ReportSettings:SenderName.
var senderName = configuration["SendGrid:SenderName"]
grzechuzz
approved these changes
Jun 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.