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 System.Net.Sockets;
using System.Net;
using Xamarin.Essentials;

namespace MobileApp
{
    class Functions
    {
       public static bool _IsOnline()
        {
            var current = Connectivity.NetworkAccess;
            
            if (current == NetworkAccess.Internet)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
public static string _DataAPI(string parameter)
        {
            string RefCountryId = App._RefCountryId;
            string RefDestinationId = App._RefDestinationId;
            string RefRestaurantId = App._RefRestaurantId;
            string RefPoiId = App._RefPoiId;

            string API = "";

                switch (parameter)
                {
                    case "OneCountry": API = "https://192.168.21.10/Robertos/api/country/read_one.php?Id=" + RefCountryId; break;
                    case "AllCountries": API = "https://192.168.21.10/Robertos/api/country/read.php"; break;
                    
                    case "OneDestination": API = "https://192.168.21.10/Robertos/api/destination/read_one.php?Id=" + RefCountryId; break;
                    case "AllDestinations": API = "https://192.168.21.10/Robertos/api/destination/read.php"; break;
                    case "AllDestinationsByCountryID": API = "https://192.168.21.10/Robertos/api/destination/read_byCountryId.php?countryId=" + RefCountryId;break;

                    case "OneRestaurant": API = "https://192.168.21.10/Robertos/api/restaurant/read_one.php?Id=" + RefRestaurantId; break;
                    case "AllRestaurants": API = "https://192.168.21.10/Robertos/api/restaurant/read.php"; break;
                    case "AllRestaurantsByDestinationID": API = "https://192.168.21.10/Robertos/api/restaurant/read_byDestinationId.php?destinationId=" + RefDestinationId; break;

                    case "OnePoi": API = "https://192.168.21.10/Robertos/api/poi/read_one.php?Id=" + RefPoiId; break;
                    case "AllPois": API = "https://192.168.21.10/Robertos/api/poi/read.php"; break;
                    case "AllPoisByDestinationID": API = "https://192.168.21.10/Robertos/api/poi/read_byDestinationId.php?destinationId=" + RefDestinationId; break;
            }
            
            return API;
        }

    }
}
