Compare commits
4 Commits
ab1f73f987
...
87031d2a0a
| Author | SHA1 | Date | |
|---|---|---|---|
| 87031d2a0a | |||
| 15680746b0 | |||
| cca6af814e | |||
| fe9b211f59 |
@@ -4,6 +4,8 @@ using DbFirst.Infrastructure;
|
|||||||
using DbFirst.Infrastructure.Repositories;
|
using DbFirst.Infrastructure.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
//TODO: create and add exception handling middleware
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using DbFirst.Domain.Entities;
|
|||||||
|
|
||||||
namespace DbFirst.Application.Catalogs;
|
namespace DbFirst.Application.Catalogs;
|
||||||
|
|
||||||
|
//TODO: create generic service to reduce code duplication
|
||||||
|
//TODO: implement CQRS pattern with MediatR
|
||||||
public class CatalogService : ICatalogService
|
public class CatalogService : ICatalogService
|
||||||
{
|
{
|
||||||
private readonly ICatalogRepository _repository;
|
private readonly ICatalogRepository _repository;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
namespace DbFirst.Application.Catalogs;
|
namespace DbFirst.Application.Catalogs;
|
||||||
|
|
||||||
|
//TODO: create generic service to reduce code duplication
|
||||||
public interface ICatalogService
|
public interface ICatalogService
|
||||||
{
|
{
|
||||||
Task<List<CatalogReadDto>> GetAllAsync(CancellationToken cancellationToken = default);
|
Task<List<CatalogReadDto>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ using DbFirst.Domain.Entities;
|
|||||||
|
|
||||||
namespace DbFirst.Domain.Repositories;
|
namespace DbFirst.Domain.Repositories;
|
||||||
|
|
||||||
|
// TODO: instead of creating interface per entity, consider using generic repository pattern (eg. IRepository<T>) to reduce code duplication.
|
||||||
|
//TODO: move to application layer as a part of clean architecture
|
||||||
public interface ICatalogRepository
|
public interface ICatalogRepository
|
||||||
{
|
{
|
||||||
Task<List<VwmyCatalog>> GetAllAsync(CancellationToken cancellationToken = default);
|
Task<List<VwmyCatalog>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public partial class ApplicationDbContext : DbContext
|
|||||||
|
|
||||||
public virtual DbSet<VwmyCatalog> VwmyCatalogs { get; set; }
|
public virtual DbSet<VwmyCatalog> VwmyCatalogs { get; set; }
|
||||||
|
|
||||||
|
// TODO: Configure column names on appsettings via IConfiguration
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<VwmyCatalog>(entity =>
|
modelBuilder.Entity<VwmyCatalog>(entity =>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Data;
|
|||||||
|
|
||||||
namespace DbFirst.Infrastructure.Repositories;
|
namespace DbFirst.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
// TODO: instead of creating implementation of repository per entity, consider using generic repository pattern (eg. Repository<T>) to reduce code duplication.
|
||||||
public class CatalogRepository : ICatalogRepository
|
public class CatalogRepository : ICatalogRepository
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _db;
|
private readonly ApplicationDbContext _db;
|
||||||
|
|||||||
Reference in New Issue
Block a user