Update CORS config; add architecture discussion comments

- Make CORS policy environment-aware: allow any origin in development, restrict to configured origins in production.
- Add detailed comments in CatalogService.cs and ICatalogRepository.cs discussing generic CRUD services, CQRS with MediatR, and repository interface placement, including both Copilot's and Hakan's perspectives.
- No functional changes to service or repository logic.
This commit is contained in:
OlgunR
2026-01-19 14:48:55 +01:00
3 changed files with 65 additions and 7 deletions

View File

@@ -6,9 +6,33 @@ using DbFirst.Domain;
namespace DbFirst.Application.Catalogs;
//TODO: create generic service to reduce code duplication
//TODO (TR): kod tekrar?n? azaltmak için generic bir servis/basit CRUD altyap?s? ekleyin
/* Copilot's Response:
A generic CRUD base service adds little value in your case:
Pros:
• Less boilerplate for simple entities without special logic.
• Uniform CRUD signatures.
Cons/Practical here:
• Domain logic differs per entity(unique title check, setting audit fields, forbidding title changes, stored procs with output GUID).
• Generic services tend to be diluted by virtual methods/hooks for special cases—ending up with per-entity overrides and little real gain.
• With stored procedures and output parameters, the pattern doesnt fit cleanly because operations arent symmetric (separate procs for insert/update/delete).
Conclusion: For this solution a generic service would be more overhead than benefit. If you later have multiple very similar entities without special logic,
you could consider a lightweight generic interface/base; for now, the specialized service implementation is cleaner. */
/* Hakan's Response:
* No, it absolutely makes sense to create a generic service using Options pattern. So, you can easily inject your SQL queries or stored procedure names via configuration.
* see: https://docs.microsoft.com/en-us/dotnet/core/extensions/options
*/
//TODO: implement CQRS pattern with MediatR
//TODO (TR): CQRS desenini MediatR ile uygulay?n
/* Hakan's response
* Here is the main part. We dont even need a service layer if we implement CQRS with MediatR at least for CRUD operations.
*/
public class CatalogService : ICatalogService
{
private readonly ICatalogRepository _repository;