Fix: Categories Edit IsActive checkbox now works both ways
Fixed two issues preventing IsActive toggle: 1. Removed hidden field that was sending "false" even when checkbox checked 2. Updated CategoryService to always update IsActive, treating null as false Checkbox behavior: - Checked → sends "true" → IsActive = true - Unchecked → sends nothing (null) → IsActive = false (via ?? operator) This allows both setting inactive→active and active→inactive. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -89,10 +89,8 @@ public class CategoryService : ICategoryService
|
||||
category.Description = updateCategoryDto.Description;
|
||||
}
|
||||
|
||||
if (updateCategoryDto.IsActive.HasValue)
|
||||
{
|
||||
category.IsActive = updateCategoryDto.IsActive.Value;
|
||||
}
|
||||
// Always update IsActive - treat null (unchecked) as false
|
||||
category.IsActive = updateCategoryDto.IsActive ?? false;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user