using Netina.Domain.Entities.Brands; namespace Netina.Repository.Handlers.Brands; public class DeleteBrandCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler { public async Task Handle(DeleteBrandCommand request, CancellationToken cancellationToken) { var ent = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(b => b.Id == request.Id, cancellationToken); if (ent == null) throw new AppException("Brand not found"); repositoryWrapper.SetRepository().Delete(ent); await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }