public void LoadData()
 {
     Rest = new RestInterfaceAsync();
     Products = new List<Product>();
     Categories = new List<Category>();
     Orders = new List<Order>();
     OrderItems = new List<OrderItem>();
     Categories = Rest.GetCategories().Result.ToList();
     Products = Rest.GetProducts().Result.ToList();
     Orders = Rest.GetOrders().Result.ToList();
     OrderItems = Rest.GetOrderItems().Result.ToList();
 }
        static void Main()
        {
            //RunAsync().Wait();
            RestInterfaceAsync rest = new RestInterfaceAsync();
            //var categories =  rest.GetCategories().Result;
            //Console.WriteLine("Id       Name        CategoryId");
            //foreach (var cat in categories)
            //{
            //    Console.WriteLine("{0}      {1}     {2}",cat.Id,cat.Name,cat.CategoryId);
            //}
            //var waiters = rest.GetWaiters().Result;
            //Console.WriteLine("Id       FirstName       LastName        Password");
            //foreach (var w in waiters)
            //{
            //    Console.WriteLine("{0}      {1}     {2}     {3}", w.Id, w.FirstName, w.LastName,w.Password);
            //}
            //var products = rest.GetProducts().Result;
            //Console.WriteLine("Id       Name        CategoryId      Price");
            //foreach (var p in products)
            //{
            //    Console.WriteLine("{0}      {1}     {2}     {3}", p.Id, p.Name, p.CategoryId,p.Price);
            //}
            //var orders = rest.GetOrders().Result;
            //Console.WriteLine("Id       TableId        Paid     Processed       WaiterId");
            //foreach (var o in orders)
            //{
            //    Console.WriteLine("{0}      {1}     {2}     {3}     {4}", o.Id, o.TableId, o.Paid,o.Processed,o.WaiterId);
            //}
            //var orderItems = rest.GetOrderItems().Result;
            //Console.WriteLine("Id       ProductId        Quantity       OrderId");
            //foreach (var i in orderItems)
            //{
            //    Console.WriteLine("{0}       {1}      {2}      {3}",i.Id,i.ProductId,i.Quantity,i.OrderId);
            //}
            //var items = rest.GetItemsInOrder(11).Result;
            //Console.WriteLine("Items in order with id 11");
            //Console.WriteLine("Id       ProductId        Quantity       OrderId");
            //foreach (var i in items)
            //{
            //    Console.WriteLine("{0}       {1}      {2}      {3}", i.Id, i.ProductId, i.Quantity, i.OrderId);
            //}
            var item = new OrderItem
            {
                Quantity = 3,
                ProductId = 21,
                OrderId = 11
            };
            //var resp = rest.AddOrderItem(11,item).Result;
            //Console.WriteLine(resp ? "Added item to existing order!" : "Error while adding item to existing order");
            //var resp = rest.DeleteOrderItem(41).Result;
            //Console.WriteLine(resp ? "Deleted item!" : "Error while deleting item!");
            //var resp = rest.DeleteOrder(21).Result;
            //Console.WriteLine(resp ? "Deleted order!" : "Error while deleting item!");

            //Console.ReadLine();
            HttpClientHandler handler = new HttpClientHandler();
            var client = new HttpClient(handler) {BaseAddress = new Uri("http://iorderonlineapp.azurewebsites.net/")};
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            Order order = new Order
            {
                OrderItems = new List<OrderItem>
                {
                    new OrderItem{
                        Quantity = 3,
                        ProductId = 21
                    }
                },
                Paid=false,
                Processed = false,
                TableId = 10
            };
            //HttpResponseMessage resp = client.PostAsJsonAsync("api/Orders", order).Result;
            //HttpResponseMessage resp = client.DeleteAsync("api/Orders/21").Result;
            //Console.WriteLine(resp.IsSuccessStatusCode ? "Added order!" : "Error!");
            //Console.WriteLine(resp.IsSuccessStatusCode ? "Deleted order!" : "Error!");

            Console.ReadLine();
        }
        public static void GetData()
        {
            Categories = new List<Category>();
            Products = new List<Product>();
            TopCategories = new List<Category>();
            ProductsByCategory = new Dictionary<int, List<Product>>();
            CategoryByParent = new Dictionary<int, List<Category>>();
            CategoryById = new Dictionary<int, string>();
            ProductById = new Dictionary<int, string>();
            //MyOrderItems = new List<OrderItem>();
            MyOrderItems = new ObservableCollection<OrderItem>();
            MyOrder = new Order();
            MyTableId = 0;
            Rest = new RestInterfaceAsync();

                Categories = Rest.GetCategories().Result.ToList();
                Products = Rest.GetProducts().Result.ToList();
        }