mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Prevents adding duplicate application names
Adds a validation check to ensure application names are unique. If a user attempts to add an application with a name that already exists, a warning message is displayed, and the operation is cancelled.
This commit is contained in:
@@ -57,6 +57,12 @@ function Add-BYOApplication {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
$listView = $State.Controls.lstApplications
|
$listView = $State.Controls.lstApplications
|
||||||
|
# Check for duplicate names
|
||||||
|
$existingApp = $listView.Items | Where-Object { $_.Name -eq $name }
|
||||||
|
if ($existingApp) {
|
||||||
|
[System.Windows.MessageBox]::Show("An application with the name '$name' already exists.", "Duplicate Name", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||||
|
return
|
||||||
|
}
|
||||||
$priority = 1
|
$priority = 1
|
||||||
if ($listView.Items.Count -gt 0) {
|
if ($listView.Items.Count -gt 0) {
|
||||||
$priority = ($listView.Items | Measure-Object -Property Priority -Maximum).Maximum + 1
|
$priority = ($listView.Items | Measure-Object -Property Priority -Maximum).Maximum + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user