diff --git a/.version b/.version index 72b6c78..ea93b80 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.0.0.7 \ No newline at end of file +0.0.0.8 \ No newline at end of file diff --git a/NetinaShop.Api/Controller/SeedController.cs b/NetinaShop.Api/Controller/SeedController.cs index fc391d6..4b940f4 100644 --- a/NetinaShop.Api/Controller/SeedController.cs +++ b/NetinaShop.Api/Controller/SeedController.cs @@ -43,12 +43,16 @@ public class SeedController : ICarterModule if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==") throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized); Dictionary categories = new Dictionary(); - var baseCat = await mediator.Send(new CreateProductCategoryCommand("دسته بندی نشده", "محصولات دسته بندی نشده", default, - new List())); + var baseCat = await mediator.Send(new CreateProductCategoryCommand("دسته بندی نشده", "محصولات دسته بندی نشده", + true, + default, + new List()),cancellationToken); categories.Add(0,baseCat.Id); foreach (var requestDto in request) { - var lDto = await mediator.Send(new CreateProductCategoryCommand(requestDto.Name,requestDto.Description,default,new List()), cancellationToken); + var lDto = await mediator.Send(new CreateProductCategoryCommand(requestDto.Name,requestDto.Description,true,default, + + new List()), cancellationToken); categories.Add(requestDto.BaseCategoryId,lDto.Id); } diff --git a/NetinaShop.Api/NetinaShop.Api.csproj b/NetinaShop.Api/NetinaShop.Api.csproj index 6b1cc04..d7a3ba1 100644 --- a/NetinaShop.Api/NetinaShop.Api.csproj +++ b/NetinaShop.Api/NetinaShop.Api.csproj @@ -6,8 +6,8 @@ enable true Linux - 0.0.0.7 - 0.0.0.7 + 0.0.0.8 + 0.0.0.8 diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCategoryCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCategoryCommands.cs index 1747a2b..1d77941 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ProductCategoryCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCategoryCommands.cs @@ -3,6 +3,7 @@ public sealed record CreateProductCategoryCommand( string Name, string Description, + bool IsMain, Guid ParentId, List Files) : IRequest; @@ -10,6 +11,7 @@ public sealed record UpdateProductCategoryCommand( Guid Id, string Name, string Description, + bool IsMain, Guid ParentId, List Files) : IRequest; diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs index 1559631..938d68e 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs @@ -8,6 +8,7 @@ public class ProductCategorySDto : BaseDto Children { get; set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.Aggregate.cs b/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.Aggregate.cs index 38f38e6..16a92d4 100644 --- a/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.Aggregate.cs +++ b/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.Aggregate.cs @@ -2,9 +2,9 @@ public partial class ProductCategory { - public static ProductCategory Create(string name, string description) + public static ProductCategory Create(string name, string description,bool isMain) { - return new ProductCategory(name, description); + return new ProductCategory(name, description, isMain); } public void SetParent(Guid parentId) diff --git a/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.cs b/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.cs index 344dec2..d04d0b6 100644 --- a/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.cs +++ b/NetinaShop.Domain/Entities/ProductCategories/ProductCategory.cs @@ -10,10 +10,11 @@ public partial class ProductCategory : ApiEntity } - public ProductCategory(string name, string description) + public ProductCategory(string name, string description,bool isMain) { Name = name; Description = description; + IsMain = isMain; } public string Name { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Mappers/CategoryMapper.g.cs b/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs similarity index 95% rename from NetinaShop.Domain/Mappers/CategoryMapper.g.cs rename to NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs index 747f24c..a4c98e0 100644 --- a/NetinaShop.Domain/Mappers/CategoryMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs @@ -8,9 +8,9 @@ using NetinaShop.Domain.Entities.ProductCategories; namespace NetinaShop.Domain.Mappers { - public static partial class CategoryMapper + public static partial class ProductCategoryMapper { - public static ProductCategory AdaptToCategory(this ProductCategoryLDto p1) + public static ProductCategory AdaptToProductCategory(this ProductCategoryLDto p1) { return p1 == null ? null : new ProductCategory() { @@ -37,7 +37,7 @@ namespace NetinaShop.Domain.Mappers return result; } - public static Expression> ProjectToCategory => p7 => new ProductCategory() + public static Expression> ProjectToProductCategory => p7 => new ProductCategory() { Name = p7.Name, Description = p7.Description, @@ -98,7 +98,7 @@ namespace NetinaShop.Domain.Mappers }).ToList(), Id = p15.Id }; - public static ProductCategory AdaptToCategory(this ProductCategorySDto p17) + public static ProductCategory AdaptToProductCategory(this ProductCategorySDto p17) { return p17 == null ? null : new ProductCategory() { @@ -133,6 +133,7 @@ namespace NetinaShop.Domain.Mappers Description = p20.Description, IsMain = p20.IsMain, ParentId = p20.ParentId == null ? default(Guid) : (Guid)p20.ParentId, + ParentName = p20.Parent == null ? null : p20.Parent.Name, Id = p20.Id }; } @@ -148,6 +149,7 @@ namespace NetinaShop.Domain.Mappers result.Description = p21.Description; result.IsMain = p21.IsMain; result.ParentId = p21.ParentId == null ? default(Guid) : (Guid)p21.ParentId; + result.ParentName = p21.Parent == null ? null : p21.Parent.Name; result.Id = p21.Id; return result; @@ -158,6 +160,7 @@ namespace NetinaShop.Domain.Mappers Description = p23.Description, IsMain = p23.IsMain, ParentId = p23.ParentId == null ? default(Guid) : (Guid)p23.ParentId, + ParentName = p23.Parent.Name, Id = p23.Id }; diff --git a/NetinaShop.Domain/Mappers/ProductCategoryStorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/ProductCategoryStorageFileMapper.g.cs new file mode 100644 index 0000000..42e4176 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ProductCategoryStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class ProductCategoryStorageFileMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductMapper.g.cs b/NetinaShop.Domain/Mappers/ProductMapper.g.cs index d480344..c800f52 100644 --- a/NetinaShop.Domain/Mappers/ProductMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ProductMapper.g.cs @@ -238,6 +238,7 @@ namespace NetinaShop.Domain.Mappers Viewed = p36.Viewed, CategoryId = p36.CategoryId, BrandId = p36.BrandId, + CategoryName = p36.Category == null ? null : p36.Category.Name, Id = p36.Id }; } @@ -264,6 +265,7 @@ namespace NetinaShop.Domain.Mappers result.Viewed = p37.Viewed; result.CategoryId = p37.CategoryId; result.BrandId = p37.BrandId; + result.CategoryName = p37.Category == null ? null : p37.Category.Name; result.Id = p37.Id; return result; @@ -285,6 +287,7 @@ namespace NetinaShop.Domain.Mappers Viewed = p39.Viewed, CategoryId = p39.CategoryId, BrandId = p39.BrandId, + CategoryName = p39.Category.Name, Id = p39.Id }; diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index 88b913e..9036df4 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -11,5 +11,9 @@ public class MapsterRegister : IRegister config.NewConfig() .Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f => f.IsHeader) ? o.Files.FirstOrDefault(f => f.IsHeader)!.FileName : string.Empty) .TwoWays(); + + config.NewConfig() + .Map("ParentName", o => o.Parent != null ? o.Parent.Name : string.Empty) + .TwoWays(); } } \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs index 85fe110..ae441cf 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/CreateProductCategoryCommandHandler.cs @@ -12,7 +12,7 @@ public class CreateProductCategoryCommandHandler : IRequestHandler Handle(CreateProductCategoryCommand request, CancellationToken cancellationToken) { - var ent = ProductCategory.Create(request.Name, request.Description); + var ent = ProductCategory.Create(request.Name, request.Description, request.IsMain); if (request.ParentId != default) ent.SetParent(request.ParentId); foreach (var file in request.Files) diff --git a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs index 7b1049a..1bac69d 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs @@ -32,13 +32,13 @@ public class GetProductCategoriesQueryHandler : IRequestHandler().TableNoTracking .Where(b => b.Id == request.Id) - .Select(CategoryMapper.ProjectToLDto) + .Select(ProductCategoryMapper.ProjectToLDto) .FirstOrDefaultAsync(cancellationToken); if (ent == null) throw new AppException("ProductCategory not found", ApiResultStatusCode.NotFound); diff --git a/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs index d94f585..b6ed887 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs @@ -17,7 +17,7 @@ public class UpdateProductCategoryCommandHandler : IRequestHandler