update
This commit is contained in:
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>()
|
||||
|
||||
Reference in New Issue
Block a user