using LocalDataStorageWithSQLite.Models;
using LocalDataStorageWithSQLite.StorageUtils;
using Microsoft.Maui.Storage;

namespace LocalDataStorageWithSQLite
{
    public partial class MainPage : ContentPage
    {
        int count = 0;

        public MainPage()
        {
            InitializeComponent();

            //string src = "Source Sample";
            //List<string> srcs = new List<string>() { "src1", "src2", "src3", "src4", "src5" };
            //PreferenceStorage ps = new PreferenceStorage();
            //FileSystemStorage fs = new FileSystemStorage();

            //ps.Set("src", src);
            //fs.Set("srcs", srcs);

            //var fromPs = ps.Get("src");
            //var fromFs = fs.Get<List<string>>("srcs");

            //int a = 0;
        }

        public async void OnNewButtonClicked(object sender, EventArgs args)
        {
            statusMessage.Text = "";

            await App.PersonRepo.AddNewPerson(newPerson.Text);
            statusMessage.Text = App.PersonRepo.StatusMessage;
        }

        public async void OnGetButtonClicked(object sender, EventArgs args)
        {
            statusMessage.Text = "";

            List<Person> people = await App.PersonRepo.GetAllPeople();
            peopleList.ItemsSource = people;
        }
    }

}
