public async void RemoverProfessor(Professor professorDeletado)
        {
            if (professorDeletado.Id == 0 || !(Professores.Any(x => x.Id == professorDeletado.Id)))
            {
                await App.Current.MainPage.DisplayAlert("Ooops!", "O item selecionado p/ remoção não é válido!", "Ok");

                return;
            }

            var confirm = await App.Current.MainPage.DisplayAlert("Você tem certeza?", "Após a confirmação esta ação não poderá ser desfeita!", "Sim, remova!", "Cancelar");

            if (confirm)
            {
                var result = await ProfessorRepository.DeleteProfessorSqlAzureAsync(professorDeletado.Id.ToString());

                if (result)
                {
                    await App.Current.MainPage.DisplayAlert("Sucesso!", "Deletado com sucesso!", "Ok");

                    CarregarProfessores(true);
                    return;
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Oops!", "Ocorreu um erro ao remover!", "Ok");
                }
            }
        }
Esempio n. 2
0
 public async void Remover()
 {
     if (await App.Current.MainPage.DisplayAlert("Atenção?",
         string.Format("Tem certeza que deseja remover o {0}?", Selecionado.Nome), "Sim", "Não"))
     {
         if (await ProfessorRepository.DeleteProfessorSqlAzureAsync(Selecionado.Id.ToString()))
         {
             CopiaListaProfessores.Remove(Selecionado);
             await Carregar();
         }
         else
             await App.Current.MainPage.DisplayAlert(
                     "Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
     }
 }
 public async void Remover()
 {
     if (await App.Current.MainPage.DisplayAlert("Atenção",
                                                 string.Format("Tem certeza que deseja remover o {0}?", Professor.Nome), "Sim", "Não"))
     {
         if (ProfessorRepository.DeleteProfessorSqlAzureAsync(Professor.Id.ToString()).Result)
         {
             ProfessorList.Remove(Professor);
         }
         else
         {
             await App.Current.MainPage.DisplayAlert(
                 "Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
         }
     }
 }