private async void BtnCadastrarArea_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Cheguei na tela chamei o dal"); AreaEstacionamento u = new AreaEstacionamento { nome = nome.Text, qtdeVagas = Convert.ToInt32(vagas.Text), }; AreaEstacionamentoDAL areaDal = new AreaEstacionamentoDAL(); var cadastroEstada = await areaDal.CadastrarArea(u); if (cadastroEstada) { MessageBox.Show("Area cadastrada com sucesso!", "Sistema de estacionamento", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Essa Area já existe!", "Sistema Estacionamento", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task <bool> CadastrarArea(AreaEstacionamento u) { if (await BuscarAreaPorNome(u)) { Console.WriteLine("Cheguei no cadastro"); var firebaseClient = new FirebaseClient("https://parking-sharp.firebaseio.com/"); await firebaseClient .Child("areaEstacionamento") .PostAsync(u); return(true); } else { return(false); } }
public async Task <bool> BuscarAreaPorNome(AreaEstacionamento u) { Console.WriteLine("Cheguei no busca usuario"); var firebaseClient = new FirebaseClient("https://parking-sharp.firebaseio.com/"); var areaEstacionamentoList = await firebaseClient.Child("areaEstacionamento").OrderByKey().OnceAsync <AreaEstacionamento>(); Console.WriteLine($"{u.nome}"); foreach (var areaEstacionamento in areaEstacionamentoList) { Console.WriteLine($"{areaEstacionamento.Object.nome}"); if (u.nome == areaEstacionamento.Object.nome) { return(false); } } return(true); }