public async Task <IActionResult> Delete(int[] ids) { var entities = await _functionService.FindAsync(ids); if (entities.Any()) { foreach (var item in entities) { var hasSubFunctions = await _functionService.HasSubFunctions(item.Id); if (hasSubFunctions) { ModelState.TryAddModelError( string.Empty, $"Cannot delete function {item.Name} because it has sub functions."); } else { await _functionService.DeleteAsync(item); } } } return(Ok()); }