From fe9b211f59569d420e8d397d865d837ce8eabdb4 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:28:11 +0100 Subject: [PATCH 1/6] Add SqlClient using and TODO for generic repository Added Microsoft.Data.SqlClient using directive to CatalogRepository.cs. Also added a TODO comment suggesting the use of a generic repository pattern to minimize code duplication. --- DbFirst.Infrastructure/Repositories/CatalogRepository.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs index f37ed80..42b9f45 100644 --- a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs +++ b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs @@ -6,6 +6,7 @@ using System.Data; namespace DbFirst.Infrastructure.Repositories; +// TODO: instead of creating implementation of repository per entity, consider using generic repository pattern (eg. IRepository) to reduce code duplication. public class CatalogRepository : ICatalogRepository { private readonly ApplicationDbContext _db; From cca6af814ec1f28b04a62671c00e37c1b800a277 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:29:04 +0100 Subject: [PATCH 2/6] Add TODO for configuring column names via appsettings Added a TODO comment in ApplicationDbContext to suggest configuring column names using IConfiguration and appsettings. No functional changes were made. --- DbFirst.Infrastructure/ApplicationDbContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DbFirst.Infrastructure/ApplicationDbContext.cs b/DbFirst.Infrastructure/ApplicationDbContext.cs index e8825bb..278a43c 100644 --- a/DbFirst.Infrastructure/ApplicationDbContext.cs +++ b/DbFirst.Infrastructure/ApplicationDbContext.cs @@ -12,6 +12,7 @@ public partial class ApplicationDbContext : DbContext public virtual DbSet VwmyCatalogs { get; set; } + // TODO: Configure column names on appsettings via IConfiguration protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => From 15680746b0407d97b10fbd7f2b60f8ed6dc7c72d Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:30:30 +0100 Subject: [PATCH 3/6] Refactor: add TODOs for generic repository pattern Added TODO comments in ICatalogRepository and CatalogRepository to suggest adopting a generic repository pattern to reduce code duplication. Also noted the potential move of the interface to the application layer for better adherence to clean architecture principles. --- DbFirst.Domain/Repositories/ICatalogRepository.cs | 2 ++ DbFirst.Infrastructure/Repositories/CatalogRepository.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DbFirst.Domain/Repositories/ICatalogRepository.cs b/DbFirst.Domain/Repositories/ICatalogRepository.cs index 7821577..6777ef3 100644 --- a/DbFirst.Domain/Repositories/ICatalogRepository.cs +++ b/DbFirst.Domain/Repositories/ICatalogRepository.cs @@ -2,6 +2,8 @@ using DbFirst.Domain.Entities; namespace DbFirst.Domain.Repositories; +// TODO: instead of creating interface per entity, consider using generic repository pattern (eg. IRepository) to reduce code duplication. +//TODO: move to application layer as a part of clean architecture public interface ICatalogRepository { Task> GetAllAsync(CancellationToken cancellationToken = default); diff --git a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs index 42b9f45..7823d61 100644 --- a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs +++ b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs @@ -6,7 +6,7 @@ using System.Data; namespace DbFirst.Infrastructure.Repositories; -// TODO: instead of creating implementation of repository per entity, consider using generic repository pattern (eg. IRepository) to reduce code duplication. +// TODO: instead of creating implementation of repository per entity, consider using generic repository pattern (eg. Repository) to reduce code duplication. public class CatalogRepository : ICatalogRepository { private readonly ApplicationDbContext _db; From 87031d2a0ac94bfbb20b02cddbafeb4987b7d3f0 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:34:23 +0100 Subject: [PATCH 4/6] Add TODOs for middleware, generic service, and CQRS Added TODO comments in Program.cs for exception handling middleware, and in CatalogService.cs and ICatalogService.cs for creating a generic service and implementing CQRS with MediatR. No functional changes made. --- DbFirst.API/Program.cs | 2 ++ DbFirst.Application/Catalogs/CatalogService.cs | 2 ++ DbFirst.Application/Catalogs/ICatalogService.cs | 1 + 3 files changed, 5 insertions(+) diff --git a/DbFirst.API/Program.cs b/DbFirst.API/Program.cs index c406c41..aea4bfd 100644 --- a/DbFirst.API/Program.cs +++ b/DbFirst.API/Program.cs @@ -4,6 +4,8 @@ using DbFirst.Infrastructure; using DbFirst.Infrastructure.Repositories; using Microsoft.EntityFrameworkCore; +//TODO: create and add exception handling middleware + var builder = WebApplication.CreateBuilder(args); // Add services to the container. diff --git a/DbFirst.Application/Catalogs/CatalogService.cs b/DbFirst.Application/Catalogs/CatalogService.cs index c2263da..03bcf8e 100644 --- a/DbFirst.Application/Catalogs/CatalogService.cs +++ b/DbFirst.Application/Catalogs/CatalogService.cs @@ -4,6 +4,8 @@ using DbFirst.Domain.Entities; namespace DbFirst.Application.Catalogs; +//TODO: create generic service to reduce code duplication +//TODO: implement CQRS pattern with MediatR public class CatalogService : ICatalogService { private readonly ICatalogRepository _repository; diff --git a/DbFirst.Application/Catalogs/ICatalogService.cs b/DbFirst.Application/Catalogs/ICatalogService.cs index f7bc50f..47538fb 100644 --- a/DbFirst.Application/Catalogs/ICatalogService.cs +++ b/DbFirst.Application/Catalogs/ICatalogService.cs @@ -1,5 +1,6 @@ namespace DbFirst.Application.Catalogs; +//TODO: create generic service to reduce code duplication public interface ICatalogService { Task> GetAllAsync(CancellationToken cancellationToken = default); From ca563f1d0c8edd2a67baa40ea78fc2c543514016 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:45:15 +0100 Subject: [PATCH 5/6] Register DbContext and AutoMapper with DI, add TODOs Added ApplicationDbContext and AutoMapper registrations to the DI container in Program.cs. Included TODO comments to extract these registrations into extension methods for better reuse across projects. --- DbFirst.API/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DbFirst.API/Program.cs b/DbFirst.API/Program.cs index aea4bfd..cfb6fc7 100644 --- a/DbFirst.API/Program.cs +++ b/DbFirst.API/Program.cs @@ -23,9 +23,11 @@ builder.Services.AddCors(options => }); }); +// TODO: Create extension method for this in Infrastructure layer in case of using in multiple projects builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); +// TODO: Create extension method for this in Application layer in case of using in multiple projects builder.Services.AddAutoMapper(typeof(CatalogProfile).Assembly, typeof(ApplicationDbContext).Assembly); builder.Services.AddScoped(); From 910b0e4aaa0702ec2be6e4828690c4274b418a9c Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 13:46:51 +0100 Subject: [PATCH 6/6] Add default CORS policy allowing any origin Configured CORS support with a default policy that allows requests from any origin. Added a TODO to restrict allowed origins using values from appsettings.json in the future. --- DbFirst.API/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DbFirst.API/Program.cs b/DbFirst.API/Program.cs index cfb6fc7..07ce535 100644 --- a/DbFirst.API/Program.cs +++ b/DbFirst.API/Program.cs @@ -13,6 +13,7 @@ builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +// TODO: allow listed origins configured in appsettings.json builder.Services.AddCors(options => { options.AddDefaultPolicy(policy =>