-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Open
Description
Let us change the code from
public virtual async Task DeleteCategoryAsync(Category category)
{
await _categoryRepository.DeleteAsync(category);
//reset a "Parent category" property of all child subcategories
var subcategories = await GetAllCategoriesByParentCategoryIdAsync(category.Id, true);
foreach (var subcategory in subcategories)
{
subcategory.ParentCategoryId = 0;
await UpdateCategoryAsync(subcategory);
}
}
TO
public virtual async Task DeleteCategoryAsync(Category category)
{
await _categoryRepository.DeleteAsync(category);
//reset a "Parent category" property of all child subcategories
var subcategories = await GetAllCategoriesByParentCategoryIdAsync(category.Id, true);
foreach (var subcategory in subcategories)
{
subcategory.ParentCategoryId = 0;
}
await _categoryRepository.UpdateAsync(subcategories);
}