Skip to content

Conversation

kamilbaczek
Copy link
Collaborator

@kamilbaczek kamilbaczek commented Aug 26, 2025

• Introduce IOptions to fetch configuration data instead of leveraging IConfiguration abstraction. This makes options easier to maintain and validate. ⚙️

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the options pattern for database connection strings across all modules, replacing direct configuration access with strongly-typed options classes that include validation.

  • Introduces persistence options classes for each module (Reports, Passes, Offers, Contracts) with required connection string properties
  • Updates database connection factories and modules to use IOptions pattern instead of direct IConfiguration access
  • Adds validation on startup to ensure connection strings are properly configured

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ReportsModule.cs Updates AddReports method to accept IConfiguration parameter for options configuration
ReportsPersistenceOptions.cs New options class for Reports module with required connection string property
DatabaseConnectionFactory.cs Refactored to use IOptions instead of IConfiguration
DataAccessModule.cs New module file implementing options pattern with validation for Reports
Program.cs Updates Reports module registration to pass configuration
PassesPersistenceOptions.cs New options class for Passes module with required connection string property
Passes/DatabaseModule.cs Refactored to use options pattern with validation instead of direct configuration access
OffersPersistenceOptions.cs New options class for Offers module with required connection string property
Offers/DatabaseModule.cs Refactored to use options pattern with validation instead of direct configuration access
Contracts/DatabaseModule.cs Refactored to use options pattern with validation instead of direct configuration access
ContractsPersistenceOptions.cs New options class for Contracts module with required connection string property

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +5 to +8
internal sealed class ReportsPersistenceOptions
{
public const string SectionName = "ConnectionStrings";

Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section name "ConnectionStrings" is duplicated across all persistence options classes. Consider creating a shared constant or base class to avoid code duplication and ensure consistency.

Suggested change
internal sealed class ReportsPersistenceOptions
{
public const string SectionName = "ConnectionStrings";
internal static class PersistenceOptionsConstants
{
public const string SectionName = "ConnectionStrings";
}
internal sealed class ReportsPersistenceOptions
{
public const string SectionName = PersistenceOptionsConstants.SectionName;

Copilot uses AI. Check for mistakes.

Comment on lines +5 to +8
internal sealed class PassesPersistenceOptions
{
public const string SectionName = "ConnectionStrings";

Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section name "ConnectionStrings" is duplicated across all persistence options classes. Consider creating a shared constant or base class to avoid code duplication and ensure consistency.

Suggested change
internal sealed class PassesPersistenceOptions
{
public const string SectionName = "ConnectionStrings";
internal static class PersistenceOptionsConstants
{
public const string SectionName = "ConnectionStrings";
}
internal sealed class PassesPersistenceOptions
{
public const string SectionName = PersistenceOptionsConstants.SectionName;

Copilot uses AI. Check for mistakes.

Comment on lines +5 to +8
internal sealed class OffersPersistenceOptions
{
public const string SectionName = "ConnectionStrings";

Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section name "ConnectionStrings" is duplicated across all persistence options classes. Consider creating a shared constant or base class to avoid code duplication and ensure consistency.

Suggested change
internal sealed class OffersPersistenceOptions
{
public const string SectionName = "ConnectionStrings";
internal static class PersistenceOptionSectionNames
{
public const string ConnectionStrings = "ConnectionStrings";
}
internal sealed class OffersPersistenceOptions
{
// Use PersistenceOptionSectionNames.ConnectionStrings where needed

Copilot uses AI. Check for mistakes.

Comment on lines +5 to +8
internal sealed class ContractsPersistenceOptions
{
public const string SectionName = "ConnectionStrings";

Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section name "ConnectionStrings" is duplicated across all persistence options classes. Consider creating a shared constant or base class to avoid code duplication and ensure consistency.

Suggested change
internal sealed class ContractsPersistenceOptions
{
public const string SectionName = "ConnectionStrings";
internal static class PersistenceOptionsConstants
{
public const string SectionName = "ConnectionStrings";
}
internal sealed class ContractsPersistenceOptions
{
// Use PersistenceOptionsConstants.SectionName where needed

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant