SleepHunter.Views.StaffEditorWindow.ValidateStaff C# (CSharp) Method

ValidateStaff() private method

private ValidateStaff ( ) : bool
return bool
        bool ValidateStaff()
        {
            string staffName = nameTextBox.Text.Trim();
              int level = (int)levelUpDown.Value;
              bool isMedenia = isAbilityLevelCheckBox.IsChecked.Value;
              bool nameChanged = originalName == null || !string.Equals(originalName, staffName, StringComparison.OrdinalIgnoreCase);

              if (string.IsNullOrWhiteSpace(staffName))
              {
            this.ShowMessageBox("Invalid Name",
               "Staff names must not be null or empty.",
               "This includes whitespace characters.",
               MessageBoxButton.OK,
               420, 220);

            nameTextBox.Focus();
            nameTextBox.SelectAll();
            return false;
              }

              if (nameChanged && StaffMetadataManager.Instance.ContainsStaff(staffName))
              {
            this.ShowMessageBox("Duplicate Name",
               "A staff already exists with the same name.",
               "Skill names are case-insenstive.",
               MessageBoxButton.OK,
               420, 220);

            nameTextBox.Focus();
            nameTextBox.SelectAll();
            return false;
              }

              staff.Name = staffName;
              staff.Level = isMedenia ? 0 : level;
              staff.AbilityLevel = isMedenia ? level : 0;
              staff.Class = GetPlayerClass();
              return true;
        }