From de7a70c6c95e34b512fa42d94ce317378d0c7dc6 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Fri, 7 Jun 2024 23:03:54 +0330 Subject: [PATCH] refactor(ProductCategoriesPage) , refactor(ICrudApiRest) - NEW VERSION OF PRODUCT CATEGORIES PAGE - Change products categories page style and ux - Change icrud api rest and get guid in instead of dto or model --- Netina.Api/Controllers/SeedController.cs | 4 ++-- .../CommandQueries/Commands/ProductCategoryCommands.cs | 2 +- Netina.Domain/Dtos/SmallDtos/ProductCategorySDto.cs | 4 ++++ .../CreateProductCategoryCommandHandler.cs | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Netina.Api/Controllers/SeedController.cs b/Netina.Api/Controllers/SeedController.cs index 6775979..753c4aa 100644 --- a/Netina.Api/Controllers/SeedController.cs +++ b/Netina.Api/Controllers/SeedController.cs @@ -79,13 +79,13 @@ public class SeedController : ICarterModule true, default, new List()),cancellationToken); - categories.Add(0,baseCat.Id); + categories.Add(0,baseCat); foreach (var requestDto in request) { var lDto = await mediator.Send(new CreateProductCategoryCommand(requestDto.Name,requestDto.Description,true,default, new List()), cancellationToken); - categories.Add(requestDto.BaseCategoryId,lDto.Id); + categories.Add(requestDto.BaseCategoryId,lDto); } diff --git a/Netina.Domain/CommandQueries/Commands/ProductCategoryCommands.cs b/Netina.Domain/CommandQueries/Commands/ProductCategoryCommands.cs index 2b26b60..ac59a28 100644 --- a/Netina.Domain/CommandQueries/Commands/ProductCategoryCommands.cs +++ b/Netina.Domain/CommandQueries/Commands/ProductCategoryCommands.cs @@ -5,7 +5,7 @@ public sealed record CreateProductCategoryCommand( string Description, bool IsMain, Guid ParentId, - List Files) : IRequest; + List Files) : IRequest; public sealed record UpdateProductCategoryCommand( Guid Id, diff --git a/Netina.Domain/Dtos/SmallDtos/ProductCategorySDto.cs b/Netina.Domain/Dtos/SmallDtos/ProductCategorySDto.cs index edbab70..790b7d6 100644 --- a/Netina.Domain/Dtos/SmallDtos/ProductCategorySDto.cs +++ b/Netina.Domain/Dtos/SmallDtos/ProductCategorySDto.cs @@ -11,4 +11,8 @@ public class ProductCategorySDto : BaseDto Children { get; set; } = new(); + + public int Index { get; set; } + public bool IsSelected { get; set; } + public bool AddNewCatVisibility { get; set; } } \ No newline at end of file diff --git a/Netina.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs b/Netina.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs index 0cb8744..5d8db21 100644 --- a/Netina.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs +++ b/Netina.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs @@ -1,6 +1,6 @@ namespace Netina.Repository.Handlers.ProductCategories; -public class CreateProductCategoryCommandHandler : IRequestHandler +public class CreateProductCategoryCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; @@ -9,7 +9,7 @@ public class CreateProductCategoryCommandHandler : IRequestHandler Handle(CreateProductCategoryCommand request, CancellationToken cancellationToken) + public async Task Handle(CreateProductCategoryCommand request, CancellationToken cancellationToken) { var ent = ProductCategory.Create(request.Name, request.Description, request.IsMain); if (request.ParentId != default) @@ -20,6 +20,6 @@ public class CreateProductCategoryCommandHandler : IRequestHandler().Add(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); - return ent.AdaptToLDto(); + return ent.Id; } } \ No newline at end of file