Changed models, added Application layer models
This commit is contained in:
		| @@ -2,39 +2,38 @@ | ||||
| using Infrastructure.Database.Generic; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
|  | ||||
| namespace Infrastructure.Database | ||||
| namespace Infrastructure.Database; | ||||
|  | ||||
| public class DbContext(DbContextOptions<DbContext> opts) | ||||
|     : Microsoft.EntityFrameworkCore.DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork | ||||
| { | ||||
|     public class DbContext(DbContextOptions<DbContext> opts) | ||||
|         : Microsoft.EntityFrameworkCore.DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork | ||||
|     protected override void OnModelCreating(ModelBuilder modelBuilder) | ||||
|     { | ||||
|         protected override void OnModelCreating(ModelBuilder modelBuilder) | ||||
|         { | ||||
|             modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); | ||||
|         } | ||||
|  | ||||
|         async Task IGenericWriter.AddAsync<T>(T entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             await AddAsync(entity, cancellationToken); | ||||
|         } | ||||
|  | ||||
|         void IGenericWriter.Update<T>(T entity) | ||||
|         { | ||||
|             Update(entity); | ||||
|         } | ||||
|  | ||||
|         void IGenericWriter.Remove<T>(T entity) | ||||
|         { | ||||
|             Remove(entity); | ||||
|         } | ||||
|  | ||||
|         IQueryable<T> IGenericReader.GetAll<T>() | ||||
|         { | ||||
|             return Set<T>(); | ||||
|         } | ||||
|  | ||||
|         async Task IUnitOfWork.SaveAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             await SaveChangesAsync(cancellationToken); | ||||
|         } | ||||
|         modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); | ||||
|     } | ||||
| } | ||||
|  | ||||
|     async Task IGenericWriter.AddAsync<T>(T entity, CancellationToken cancellationToken) | ||||
|     { | ||||
|         await AddAsync(entity, cancellationToken); | ||||
|     } | ||||
|  | ||||
|     void IGenericWriter.Update<T>(T entity) | ||||
|     { | ||||
|         Update(entity); | ||||
|     } | ||||
|  | ||||
|     void IGenericWriter.Remove<T>(T entity) | ||||
|     { | ||||
|         Remove(entity); | ||||
|     } | ||||
|  | ||||
|     IQueryable<T> IGenericReader.GetAll<T>() | ||||
|     { | ||||
|         return Set<T>(); | ||||
|     } | ||||
|  | ||||
|     async Task IUnitOfWork.SaveAsync(CancellationToken cancellationToken) | ||||
|     { | ||||
|         await SaveChangesAsync(cancellationToken); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user