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
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SinglePoi : ContentPage
    {
        public SinglePoi()
        {
            InitializeComponent();

            BindingContext = new SinglePoiViewModel();

            GetPoi();
        }
        public async void GetPoi()
        {
            string RefPoiId = App._RefPoiId;

            var client = new System.Net.Http.HttpClient();

            string returnArray = (await client.GetAsync(Functions._DataAPI("OnePoi"))).Content.ReadAsStringAsync().Result;

            PoiModel resultParse = new PoiModel();
            if (returnArray != "")
            {
                resultParse = JsonConvert.DeserializeObject<PoiModel>(returnArray);
            }

            //this.BindingContext = resultParse.Records;
            SinglePoiView.ItemsSource = resultParse.Records;
        }
    }
}