initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
|
||||
namespace Indotalent.Features.Serilogs.Database;
|
||||
|
||||
|
||||
|
||||
public record DeleteSerilogLogsByIdCommand(int Id) : IRequest<bool>;
|
||||
|
||||
|
||||
public class DeleteSerilogLogsByIdHandler :
|
||||
IRequestHandler<DeleteSerilogLogsByIdCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public DeleteSerilogLogsByIdHandler(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(DeleteSerilogLogsByIdCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var log = await _context.Set<Data.Entities.SerilogLogs>().FindAsync(request.Id);
|
||||
if (log == null) return false;
|
||||
|
||||
_context.Set<Data.Entities.SerilogLogs>().Remove(log);
|
||||
return await _context.SaveChangesAsync(cancellationToken) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user