private void Submit(object sender, System.Windows.RoutedEventArgs e)
{
decimal priority = DEFAULT_RULE_PRIORITY;
Decimal.TryParse(m_rulePriority.Text, out priority);
if (m_ruleToUpdate == null)
{
SimpleWizardRule rule = new SimpleWizardRule()
{
ID = Guid.Empty.ToString(), // Will be set in the manager.
Owner = "None", // Will be set in the manager.
DialPlanID = Guid.Empty.ToString(), // Will be set in the manager.
Direction = SIPCallDirection.Out.ToString(),
PatternType = ((TextBlock)m_rulePatternType.SelectedValue).Text,
Pattern = m_rulePattern.Text,
Command = ((TextBlock)m_ruleCommandType.SelectedValue).Text,
Description = m_ruleDescription.Text,
Priority = priority,
IsDisabled = m_ruleIsDisabled.IsChecked.GetValueOrDefault()
};
string commandParameterError = SetRuleCommandParameters(rule);
if (commandParameterError != null)
{
SetErrorMessage(commandParameterError);
}
else if (rule.Pattern.IsNullOrBlank())
{
SetErrorMessage("A pattern must be specified to match the outgoing call.");
}
else
{
HideError.Begin();
Add(rule);
}
}
else
{
m_ruleToUpdate.IsDisabled = m_ruleIsDisabled.IsChecked.GetValueOrDefault();
m_ruleToUpdate.PatternType = ((TextBlock)m_rulePatternType.SelectedValue).Text;
m_ruleToUpdate.Pattern = m_rulePattern.Text;
m_ruleToUpdate.Command = ((TextBlock)m_ruleCommandType.SelectedValue).Text;
m_ruleToUpdate.Description = m_ruleDescription.Text;
m_ruleToUpdate.Priority = priority;
string commandParameterError = SetRuleCommandParameters(m_ruleToUpdate);
if (commandParameterError != null)
{
SetErrorMessage(commandParameterError);
}
else if (m_ruleToUpdate.Pattern.IsNullOrBlank())
{
SetErrorMessage("A pattern must be specified to match the outgoing call.");
}
else
{
HideError.Begin();
Update(m_ruleToUpdate);
}
}
}