Skip to content

Commit

Permalink
Address pr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fredpetersen committed Feb 13, 2024
1 parent 5028b8d commit ff2b7cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions coffeecard/CoffeeCard.Library/Services/v2/MenuItemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public async Task<MenuItemResponse> UpdateMenuItemAsync(int id, UpdateMenuItemRe
throw new ConflictException($"Menu item already exists with name {changedMenuItem.Name}");
}

if (!changedMenuItem.Active &&
await _context.Products.AnyAsync(p => p.EligibleMenuItems.Any(menuItem => menuItem.Id == id)))

var menuItemIsUsed = await _context.Products.AnyAsync(p => p.EligibleMenuItems.Any(menuItem => menuItem.Id == id));
if (!changedMenuItem.Active && menuItemIsUsed)
{
throw new ConflictException("Menu item is in use and cannot be disabled");
}
Expand Down

0 comments on commit ff2b7cc

Please sign in to comment.