public void AddFunctionToRole(int roleId, int[] functions) { var role = roleService.FindById(roleId); foreach (var item in functions) { var function = functionService.FindById(item); if (!role.Functions.Contains(function)) { role.Functions.Add(function); } } }