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>()
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CategoryConfiguration : IEntityTypeConfiguration<Category>
|
||||
|
||||
builder
|
||||
.HasOne(entity => entity.Parent)
|
||||
.WithMany(entity => entity.Categories)
|
||||
.WithMany(entity => entity.Categorys)
|
||||
.HasForeignKey(entity => entity.ParentId)
|
||||
.IsRequired(false);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.119</Version>
|
||||
<Version>0.0.121</Version>
|
||||
<DebugType>None</DebugType>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
@@ -40,6 +40,7 @@
|
||||
<Protobuf Include="Protos\contract.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\usercontract.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\pruductcategory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\category.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\tag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\pruducttag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class CreateNewCategoryRequestValidator : AbstractValidator<CreateNewCategoryRequest>
|
||||
|
||||
Reference in New Issue
Block a user