using Example.Connectors;
using Example.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Example.Helpers
{
    public class CreateTaxiList
    {
        public static Dictionary<string, TaxiDataModule> _TaxiList = new Dictionary<string, TaxiDataModule>();


        //Get Total Pages from the packs and Loop into them to create a Category List With Packs information in the model CategoryPacksList
        public static async Task GetTaxiList()
        {

            try
            {
                List<TaxiDataModule> listTaxis = await GetTaxis.LoadTaxis(GetLogedInServer._currentServerLoggedOn.serverID);
                if (listTaxis == null)
                {
                    throw new NullReferenceException("Can't load taxi List");
                }
                else
                {
                    foreach (TaxiDataModule taxi in listTaxis)
                    {
                        if (taxi.enabled == true)
                        {
                            var dictaxis = new TaxiDataModule();
                            dictaxis.id = taxi.id;
                            dictaxis.locationName = taxi.locationName;
                            dictaxis.discordRoles = taxi.discordRoles;
                            dictaxis.locationPrice = taxi.locationPrice;
                            dictaxis.enabled = taxi.enabled;
                            _TaxiList.Add(taxi.locationName, dictaxis);
                        }
                        else { }
                    }
                }


            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Source + ex.Message + ex.Data + ex.StackTrace);
            }
        }
    }
}
