namespace Visor.Models
{
    public class AllPubData
    {
        public static List<ObjectItems> ListObjectItems { get; set; } = new();
        public static List<DeviceItems> ListDeviceItems { get; set; } = new();
        public static List<DeviceTypeItems> ListDeviceTypeItems { get; set; } = new();
        public static HttpClient http { get; set; } = new()
        {
            BaseAddress = new Uri("http://localhost:5262/")
        };

        public static Task GetAll() => _GetAllData();
        public static Task GetObjects() => _GetObject();
        public static Task GetType() => _GetType();
        public static Task GetDevice() => _GetDevice();

        private static async Task _GetAllData()
        {
            var o = await _GetObject();
            var t = await _GetType();
            var d = await _GetDevice();
        }
        private static async Task<List<ObjectItems>> _GetObject()
        {
            return ListObjectItems = await http.GetFromJsonAsync<List<ObjectItems>>("api/Object/GetObject");
        }
        private static async Task<List<DeviceItems>> _GetDevice()
        {
            return ListDeviceItems = http.GetFromJsonAsync<List<DeviceItems>>("api/Device/GetDevices").Result.Take(100).ToList();
        }
        private static async Task<List<DeviceTypeItems>> _GetType()
        {
            return ListDeviceTypeItems = await http.GetFromJsonAsync<List<DeviceTypeItems>>("api/Type/GetTypes");
        }

    }
}
