fix: Handle null values in response categories and map properties correctly in GetDiscountCategoriesQueryHandler
Build and Deploy / build (push) Successful in 1m52s
Build and Deploy / build (push) Successful in 1m52s
This commit is contained in:
+5
-5
@@ -25,7 +25,7 @@ public class GetDiscountCategoriesQueryHandler : IRequestHandler<GetDiscountCate
|
|||||||
|
|
||||||
return new GetDiscountCategoriesResponseDto
|
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,
|
Id = node.Id,
|
||||||
Name = node.Name,
|
Name = node.Name,
|
||||||
Title = node.Title,
|
Title = node.Title,
|
||||||
Description = string.IsNullOrWhiteSpace(node.Description) ? node.Description : string.Empty,
|
Description = !string.IsNullOrWhiteSpace(node.Description) ? node.Description : string.Empty,
|
||||||
ImagePath =string.IsNullOrWhiteSpace(node.ImagePath)? node.ImagePath : string.Empty,
|
ImagePath = !string.IsNullOrWhiteSpace(node.ImagePath) ? node.ImagePath : string.Empty,
|
||||||
ParentCategoryId = node.ParentCategoryId!=null? node.ParentCategoryId.Value : null,
|
ParentCategoryId = node.ParentCategoryId != 0 ? node.ParentCategoryId : null,
|
||||||
SortOrder = node.SortOrder,
|
SortOrder = node.SortOrder,
|
||||||
IsActive = node.IsActive,
|
IsActive = node.IsActive,
|
||||||
ProductCount = node.ProductCount,
|
ProductCount = node.ProductCount,
|
||||||
Created = DateTime.UtcNow, // Proto doesn't have created field
|
Created = DateTime.UtcNow, // Proto doesn't have created field
|
||||||
ChildCategories = node.Children.Select(MapCategory).ToList()
|
ChildCategories = node.Children?.Select(MapCategory).ToList() ?? new List<DiscountCategoryTreeDto>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user