'load data from firebase database into Xamarin form
I'm trying to do get data from firebase database into ui in xamarin form application but it's not loaded, just label Today Appointment are, and nothing else, so what is the problem ?
Service :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CCSN.Models;
using Firebase.Database;
using Newtonsoft.Json;
namespace CCSN.Services
{
public class SpecalistService
{
FirebaseClient firebaseClient = new FirebaseClient("https://ccsn-fed2d-default-rtdb.firebaseio.com/");
public async Task<bool> Save(Specalist specalist)
{
var data = await firebaseClient.Child("Specalists").PostAsync(JsonConvert.SerializeObject(specalist));
if (string.IsNullOrEmpty(data.Key))
{
return true;
}
return false;
}
public async Task<List<Specalist>> GetAll()
{
return (await firebaseClient
.Child("Specalists")
.OnceAsync<Specalist>()).Select(item => new Specalist
{
Email = item.Object.Email,
Name = item.Object.Name,
ID = item.Object.ID,
Patients = item.Object.Patients.ToList()
}).ToList();
}
public async Task<bool> Update(Specalist specalist)
{
await firebaseClient.Child("Specalists" + "/" + specalist.ID).PatchAsync(JsonConvert.SerializeObject(specalist));
return true;
}
}
}
view Model :
using CCSN.Models;
using CCSN.Services;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace CCSN.ViewModels
{
public class HomePageModelView : BindableObject
{
public SpecalistService specalistService;
public List<Specalist> specs;
public HomePageModelView()
{
specs = new List<Specalist>();
specalistService = new SpecalistService();
Button_ClickedAsync();
}
async private void Button_ClickedAsync()
{
specs = await specalistService.GetAll();
specs.ForEach(spec => Console.WriteLine(spec.Name));
}
}
}
I'm trying to do get data from firebase database into ui in xamarin form application but it's not loaded, just label Today Appointment are, and nothing else, so what is the problem ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
