Esempio n. 1
0
        public async Task <ActionResult> Delete(Guid id)
        {
            try
            {
                var professor = await _professorRepository.GetProfessorById(id);

                var statusCode = await _accountRepository.DeleteAccount(professor.Email);

                if (statusCode == HttpStatusCode.NotFound)
                {
                    return(HttpNotFound());
                }

                statusCode = await _professorRepository.DeleteProfessor(id);

                if (statusCode == HttpStatusCode.NotFound)
                {
                    return(HttpNotFound());
                }

                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (BadRequestException bre)
            {
                var errorString = GetErrorsFromAdycHttpExceptionToString(bre);

                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, errorString));
            }
        }
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.DeleteProfessor(Selecionado.Id.ToString()))
         {
             CopiarListaProfessores.Remove(Selecionado);
             await Carregar();
         }
         else
         {
             await App.Current.MainPage.DisplayAlert("Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
         }
     }
 }
        private void _professorDeletionButton_Click(object sender, EventArgs e)
        {
            var tempItem = int.Parse(profDelete.Split(":")[1]);

            for (int i = 0; i < thisProfList.Count; i++)
            {
                if (thisProfList[i].Id == tempItem)
                {
                    _professorAdapter.RemoveFromProfList(thisProfList[i]);
                    thisProfList.Remove(thisProfList[i]);
                    thisRepository.DeleteProfessor(thisProfList);
                    thisProfString = new List <string>();
                    thisProfString = setProfSpinner();
                    var adapter           = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, thisProfString);
                    var spinnerProfDelete = FindViewById <Spinner>(Resource.Id.ProfessorDeleteSpinner);
                    var profSpinnerEdit   = FindViewById <Spinner>(Resource.Id.professorIdEdit);
                    spinnerProfDelete.Adapter = adapter;
                    profSpinnerEdit.Adapter   = adapter;
                    _professorAdapter.NotifyDataSetChanged();
                    return;
                }
            }
        }