Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f44e3bdd2b | ||
|
|
9780168b45 |
@@ -17,8 +17,8 @@ namespace CleanArchitecture.Application.Contracts.Persistence
|
|||||||
bool disableTracking = true);
|
bool disableTracking = true);
|
||||||
Task<T> GetByIdAsync(Guid id);
|
Task<T> GetByIdAsync(Guid id);
|
||||||
|
|
||||||
Task<T> AddAsync(T entity);
|
Task<T> AddAsync(T entity, string userThatMakesAction = "");
|
||||||
Task<T> UpdateAsync(T entity);
|
Task<T> UpdateAsync(T entity, string userThatMakesAction = "");
|
||||||
Task DeleteAsync(T entity);
|
Task DeleteAsync(T entity);
|
||||||
|
|
||||||
void AddEntity(T entity);
|
void AddEntity(T entity);
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ namespace CleanArchitecture.Application.Contracts.Persistence
|
|||||||
IVideoRepository VideoRepository { get; }
|
IVideoRepository VideoRepository { get; }
|
||||||
IAsyncRepository<T> Repository<T>() where T : BaseDomainModel;
|
IAsyncRepository<T> Repository<T>() where T : BaseDomainModel;
|
||||||
|
|
||||||
Task<int> Complete();
|
Task<int> Complete(string userThatMakesAction = "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ namespace CleanArchitecture.Application.Features.Videos.Commands.CreateVideo
|
|||||||
{
|
{
|
||||||
public string Nombre { get; set; } = string.Empty;
|
public string Nombre { get; set; } = string.Empty;
|
||||||
public Guid StreamerId { get; set; }
|
public Guid StreamerId { get; set; }
|
||||||
|
public string UserThatMakesAction { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace CleanArchitecture.Application.Features.Videos.Commands.CreateVideo
|
|||||||
{
|
{
|
||||||
var videoEntity = mapper.Map<Video>(request);
|
var videoEntity = mapper.Map<Video>(request);
|
||||||
unitOfWork.VideoRepository.AddEntity(videoEntity);
|
unitOfWork.VideoRepository.AddEntity(videoEntity);
|
||||||
var response = await unitOfWork.Complete();
|
var response = await unitOfWork.Complete(request.UserThatMakesAction);
|
||||||
if(response > 0)
|
if(response > 0)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"Video {videoEntity.Id} is successfully created.");
|
logger.LogInformation($"Video {videoEntity.Id} is successfully created.");
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ namespace CleanArchitecture.Application.Features.Videos.Commands.UpdateVideo
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Nombre { get; set; } = string.Empty;
|
public string Nombre { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string UserThatMakesAction { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace CleanArchitecture.Application.Features.Videos.Commands.UpdateVideo
|
|||||||
mapper.Map(request, videoToUpdate, typeof(UpdateVideoCommand), typeof(Video));
|
mapper.Map(request, videoToUpdate, typeof(UpdateVideoCommand), typeof(Video));
|
||||||
|
|
||||||
unitOfWork.VideoRepository.UpdateEntity(videoToUpdate);
|
unitOfWork.VideoRepository.UpdateEntity(videoToUpdate);
|
||||||
await unitOfWork.Complete();
|
await unitOfWork.Complete(request.UserThatMakesAction);
|
||||||
|
|
||||||
logger.LogInformation($"Video {videoToUpdate.Id} is successfully updated.");
|
logger.LogInformation($"Video {videoToUpdate.Id} is successfully updated.");
|
||||||
|
|
||||||
|
|||||||
@@ -30,19 +30,21 @@ namespace CleanArchitecture.Infrastructure.Persistence
|
|||||||
// .EnableSensitiveDataLogging();
|
// .EnableSensitiveDataLogging();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
public Task<int> SaveChangesAsync(string? userThatMakesAction = "", CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
userThatMakesAction = userThatMakesAction ?? "System";
|
||||||
|
|
||||||
foreach (var entry in ChangeTracker.Entries<BaseDomainModel>())
|
foreach (var entry in ChangeTracker.Entries<BaseDomainModel>())
|
||||||
{
|
{
|
||||||
switch (entry.State)
|
switch (entry.State)
|
||||||
{
|
{
|
||||||
case EntityState.Modified:
|
case EntityState.Modified:
|
||||||
entry.Entity.LastModifiedBy = "System";
|
entry.Entity.LastModifiedBy = userThatMakesAction;
|
||||||
entry.Entity.LastModifiedDate = DateTime.Now;
|
entry.Entity.LastModifiedDate = DateTime.Now;
|
||||||
break;
|
break;
|
||||||
case EntityState.Added:
|
case EntityState.Added:
|
||||||
entry.Entity.CreatedDate = DateTime.Now;
|
entry.Entity.CreatedBy = userThatMakesAction;
|
||||||
entry.Entity.CreatedBy = "System";
|
entry.Entity.CreatedDate = DateTime.Now;
|
||||||
break;
|
break;
|
||||||
case EntityState.Detached:
|
case EntityState.Detached:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ namespace CleanArchitecture.Infrastructure.Persistence
|
|||||||
public class StreamerDbContextSeed
|
public class StreamerDbContextSeed
|
||||||
{
|
{
|
||||||
|
|
||||||
public static async Task SeedAsync(StreamerDbContext context, ILogger<StreamerDbContextSeed> logger)
|
public static async Task SeedAsync(StreamerDbContext context, ILogger<StreamerDbContextSeed> logger, string userThatMakesAction = "")
|
||||||
{
|
{
|
||||||
if (!context.Streamers.Any())
|
if (!context.Streamers.Any())
|
||||||
{
|
{
|
||||||
context.AddRange(GetPreconfiguredStreamers());
|
context.AddRange(GetPreconfiguredStreamers());
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync(userThatMakesAction);
|
||||||
logger.LogInformation("Seed database associated with context {DbContextName} executed", typeof(StreamerDbContext).Name);
|
logger.LogInformation("Seed database associated with context {DbContextName} executed", typeof(StreamerDbContext).Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,18 +60,18 @@ namespace CleanArchitecture.Infrastructure.Repositories
|
|||||||
return await context.Set<T>().FindAsync(id);
|
return await context.Set<T>().FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<T> AddAsync(T entity)
|
public async Task<T> AddAsync(T entity, string userThatMakesAction = "")
|
||||||
{
|
{
|
||||||
context.Set<T>().Add(entity);
|
context.Set<T>().Add(entity);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync(userThatMakesAction);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<T> UpdateAsync(T entity)
|
public async Task<T> UpdateAsync(T entity, string userThatMakesAction = "")
|
||||||
{
|
{
|
||||||
context.Set<T>().Attach(entity);
|
context.Set<T>().Attach(entity);
|
||||||
context.Entry(entity).State = EntityState.Modified;
|
context.Entry(entity).State = EntityState.Modified;
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync(userThatMakesAction);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ namespace CleanArchitecture.Infrastructure.Repositories
|
|||||||
|
|
||||||
public StreamerDbContext StreamerDbContext => context;
|
public StreamerDbContext StreamerDbContext => context;
|
||||||
|
|
||||||
public async Task<int> Complete()
|
public async Task<int> Complete(string userThatMakesAction = "")
|
||||||
{
|
{
|
||||||
return await context.SaveChangesAsync();
|
return await context.SaveChangesAsync(userThatMakesAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
BIN
CleanArchitecture/comandos.txt
Normal file
BIN
CleanArchitecture/comandos.txt
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@ kind: Deployment
|
|||||||
metadata:
|
metadata:
|
||||||
name: clean-architecture-deployment
|
name: clean-architecture-deployment
|
||||||
spec:
|
spec:
|
||||||
replicas: 2
|
replicas: 16
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: clean-architecture-backend
|
app: clean-architecture-backend
|
||||||
@@ -14,7 +14,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: clean-architecture-backend
|
- name: clean-architecture-backend
|
||||||
image: dockerregistry.alexdev.es/clean-architecture-backend:0.0.48
|
image: dockerregistry.alexdev.es/clean-architecture-backend:0.0.59
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
|
|||||||
Reference in New Issue
Block a user