fix: Handle null values in response categories and map properties correctly in GetDiscountCategoriesQueryHandler
Build and Deploy / build (push) Successful in 1m52s

This commit is contained in:
masoodafar-web
2026-01-05 02:14:45 +03:30
parent f627cbf46a
commit de412dd9e5
@@ -25,7 +25,7 @@ public class GetDiscountCategoriesQueryHandler : IRequestHandler<GetDiscountCate
return new GetDiscountCategoriesResponseDto
{
Categories = response.Categories.Select(MapCategory).ToList()
Categories = response.Categories?.Select(MapCategory).ToList() ?? new List<DiscountCategoryTreeDto>()
};
}
@@ -36,14 +36,14 @@ public class GetDiscountCategoriesQueryHandler : IRequestHandler<GetDiscountCate
Id = node.Id,
Name = node.Name,
Title = node.Title,
Description = string.IsNullOrWhiteSpace(node.Description) ? node.Description : string.Empty,
ImagePath =string.IsNullOrWhiteSpace(node.ImagePath)? node.ImagePath : string.Empty,
ParentCategoryId = node.ParentCategoryId!=null? node.ParentCategoryId.Value : null,
Description = !string.IsNullOrWhiteSpace(node.Description) ? node.Description : string.Empty,
ImagePath = !string.IsNullOrWhiteSpace(node.ImagePath) ? node.ImagePath : string.Empty,
ParentCategoryId = node.ParentCategoryId != 0 ? node.ParentCategoryId : null,
SortOrder = node.SortOrder,
IsActive = node.IsActive,
ProductCount = node.ProductCount,
Created = DateTime.UtcNow, // Proto doesn't have created field
ChildCategories = node.Children.Select(MapCategory).ToList()
ChildCategories = node.Children?.Select(MapCategory).ToList() ?? new List<DiscountCategoryTreeDto>()
};
}
}