private void ButtonSaveCompetition_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(TextBoxCompetitionName.Text) || TextBoxCompetitionName.Text.Length < 3) { NotificationHelper.notifier.ShowCustomMessage("Nome da competição inválido!"); return; } if ((SeasonComboModel)ComboBoxSeason.SelectedValue == null) { NotificationHelper.notifier.ShowCustomMessage("Falta escolher a época!"); return; } if (competitionService.AlreadyExistsCompetition(TextBoxCompetitionName.Text, ((SeasonComboModel)ComboBoxSeason.SelectedValue).SeasonId)) { NotificationHelper.notifier.ShowCustomMessage("Já existe uma competição idêntica!"); return; } string compName = TextBoxCompetitionName.Text; int seasonID = ((SeasonComboModel)ComboBoxSeason.SelectedValue).SeasonId; new Thread(() => { UtilsNotification.StartLoadingAnimation(); //Save new competition if (competitionService.CreateCompetition(compName, seasonID)) { NotificationHelper.notifier.ShowCustomMessage("Competição criada com sucesso!"); //Reset UI TextBoxCompetitionName.Dispatcher.BeginInvoke((Action)(() => TextBoxCompetitionName.Clear())); LoadCompetitionsGrid(); } else { NotificationHelper.notifier.ShowCustomMessage("Ocorreu um erro ao criar a Competição!"); } UtilsNotification.StopLoadingAnimation(); }).Start(); }