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 SingleRestaurant : ContentPage
    {
        public SingleRestaurant()
        {
            InitializeComponent();
           
            BindingContext = new SingleRestaurantViewModel();

            GetRestaurant();
        }
        public async void GetRestaurant()
        {
            string RefRestaurantId = App._RefRestaurantId;

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


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

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

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