This commit is contained in:
masoodafar-web
2025-11-20 00:40:28 +03:30
parent 8a9cabf7f1
commit 7840f3b463
9 changed files with 409 additions and 197 deletions

View File

@@ -13,7 +13,7 @@ public class CreateNewCategoryCommandHandler : IRequestHandler<CreateNewCategory
CancellationToken cancellationToken)
{
var entity = request.Adapt<Category>();
await _context.Categories.AddAsync(entity, cancellationToken);
await _context.Categorys.AddAsync(entity, cancellationToken);
entity.AddDomainEvent(new CreateNewCategoryEvent(entity));
await _context.SaveChangesAsync(cancellationToken);
return entity.Adapt<CreateNewCategoryResponseDto>();

View File

@@ -11,10 +11,10 @@ public class DeleteCategoryCommandHandler : IRequestHandler<DeleteCategoryComman
public async Task<Unit> Handle(DeleteCategoryCommand request, CancellationToken cancellationToken)
{
var entity = await _context.Categories
var entity = await _context.Categorys
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Category), request.Id);
entity.IsDeleted = true;
_context.Categories.Update(entity);
_context.Categorys.Update(entity);
entity.AddDomainEvent(new DeleteCategoryEvent(entity));
await _context.SaveChangesAsync(cancellationToken);
return Unit.Value;

View File

@@ -11,10 +11,10 @@ public class UpdateCategoryCommandHandler : IRequestHandler<UpdateCategoryComman
public async Task<Unit> Handle(UpdateCategoryCommand request, CancellationToken cancellationToken)
{
var entity = await _context.Categories
var entity = await _context.Categorys
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken) ?? throw new NotFoundException(nameof(Category), request.Id);
request.Adapt(entity);
_context.Categories.Update(entity);
_context.Categorys.Update(entity);
entity.AddDomainEvent(new UpdateCategoryEvent(entity));
await _context.SaveChangesAsync(cancellationToken);
return Unit.Value;

View File

@@ -10,7 +10,7 @@ public class GetAllCategoryByFilterQueryHandler : IRequestHandler<GetAllCategory
public async Task<GetAllCategoryByFilterResponseDto> Handle(GetAllCategoryByFilterQuery request, CancellationToken cancellationToken)
{
var query = _context.Categories
var query = _context.Categorys
.ApplyOrder(sortBy: request.SortBy)
.AsNoTracking()
.AsQueryable();

View File

@@ -11,7 +11,7 @@ public class GetCategoryQueryHandler : IRequestHandler<GetCategoryQuery, GetCate
public async Task<GetCategoryResponseDto> Handle(GetCategoryQuery request,
CancellationToken cancellationToken)
{
var response = await _context.Categories
var response = await _context.Categorys
.AsNoTracking()
.Where(x => x.Id == request.Id)
.ProjectToType<GetCategoryResponseDto>()