protected override async void OnAppearing() { base.OnAppearing(); var docItem = (Usuario)BindingContext; if (docItem.TemPessoasComProbMobilidade) { temPessoasComProbMobilidadeHabilitado.IsChecked = true; temPessoasComProbMobilidadeDesabilitado.IsChecked = false; } else { temPessoasComProbMobilidadeHabilitado.IsChecked = false; temPessoasComProbMobilidadeDesabilitado.IsChecked = true; } if (!UserManager.GetLogUser().PerfilUsuario.Equals("Adm Geral")) { ListComunidade = await ComunidadeService.GetInstance().GetComunidadeList(Constants.IdComunidadeQuery, UserManager.GetLogUser().IdComunidadeUsu); } else { ListComunidade = await ComunidadeService.GetInstance().GetComunidadeList(null, null); } foreach (Comunidade condo in ListComunidade) { comunidadeUsuario.Items.Add(condo.NomeComunidade); } comunidadeUsuario.SelectedIndex = comunidadeUsuario.Items.IndexOf(docItem.ComunidadeUsuario); }
async void OnDeleteActivated(object sender, EventArgs e) { var docItem = (Comunidade)BindingContext; await ComunidadeService.GetInstance().DeleteComunidade(docItem); await Navigation.PopAsync(); }
private async void ListingCondos() { Condos = await ComunidadeService.GetInstance().GetComunidadeList(null, null); CondoList = new ObservableCollection <string>(); foreach (Comunidade condo in Condos) { CondoList.Add(condo.NomeComunidade); } }
//Utilizado para carregar a lista de cadastros de condomínios, antes da tela abrir para o usuário. protected override async void OnAppearing() { base.OnAppearing(); condoListView.ItemsSource = await ComunidadeService.GetInstance().GetComunidadeList(null, null); }
async void OnSaveActivated(object sender, EventArgs e) { try { DateTime now = DateTime.Now; var docItem = (Comunidade)BindingContext; docItem.DataAlteracaoComunidade = now; List <string> changeLog = null; if (isNewDoc) { docItem.CodigoComunidade = GenerateCodes.GeraCodigoComunidade(docItem.UFComunidade, docItem.NomeComunidade); docItem.DataCriacaoComunidade = now; StringBuilder sbLog = new StringBuilder(); sbLog.Append("- O usuário "); sbLog.Append(UserManager.GetLogUser().NomeUsuario); sbLog.Append(" criou o documento em "); sbLog.Append(now.ToString()); changeLog = new List <string>(); changeLog.Add(sbLog.ToString()); docItem.LogAlteracaoComunidade = JsonConvert.SerializeObject(changeLog); if (await ComunidadeService.GetInstance().AddComunidade(docItem)) { await DisplayAlert("Cadastro de Comunidade", "Comunidade cadastrada com sucesso!", "OK"); await Navigation.PopAsync(); } else { await DisplayAlert("Atenção!", "Esta comunidade já está cadastrada!", "OK"); } } else { StringBuilder sbLog = new StringBuilder(); sbLog.Append("- O usuário "); sbLog.Append(UserManager.GetLogUser().NomeUsuario); sbLog.Append(" alterou o documento em "); sbLog.Append(now.ToString()); changeLog = JsonConvert.DeserializeObject <List <string> >(docItem.LogAlteracaoComunidade); changeLog.Add(sbLog.ToString()); docItem.LogAlteracaoComunidade = JsonConvert.SerializeObject(changeLog); if (await ComunidadeService.GetInstance().UpdateComunidade(docItem)) { await DisplayAlert("Cadastro de Comunidade", "Comunidade salva com sucesso!", "OK"); } else { await DisplayAlert("Atenção!", "Falha ao tentar salvar a comunidade !", "OK"); } } } catch (Exception ex) { StringBuilder sbLog = new StringBuilder(); sbLog.Append("Erro ao salvar a comunidade no banco de dados!"); sbLog.Append(Environment.NewLine); sbLog.Append("Erro: "); sbLog.Append(ex.ToString()); } }