using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using System.Net.Http;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using MobileApp.ViewModels;
using MobileApp.Model;

namespace MobileApp.Views
{
    public partial class Types : ContentPage
    {
        public Types()
        {
            InitializeComponent();
            BindingContext = new TypesViewModel();
            GetTypes();
        }
        public void GetTypes()
        {
            string returnArray = "{'records':[{'Id':'1','Name':'Restaurants'},{'Id':'2','Name':'POIs'}]}";

            TypesModel resultParse = new TypesModel();
            resultParse = JsonConvert.DeserializeObject<TypesModel>(returnArray);

            ListViewTypes.ItemsSource = resultParse.Records;
        }
        async void TypesButtonClicked(object sender, EventArgs args)
        {
            /*Button button = (Button)sender;
            await Navigation.PushAsync(new Restaurants());*/

            Button button = (Button)sender;
            string parameter = button.CommandParameter.ToString();
            if (parameter == "1")
            {
                await Navigation.PushAsync(new Restaurants());
            }
            else
            {
                await Navigation.PushAsync(new Pois());
            }
            
        }
    }
}