public async Task AddTableAsync(Tables table, bool IsAvailable = false)

        {
            table.isAvailable = IsAvailable;
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Stolies.Clear();
            await StolyDataService.AddItemAsync(table);

            var items = await StolyDataService.GetItemsAsync(true);

            try
            {
                foreach (var item in items)
                {
                    Stolies.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        /// <summary>
        /// Vrat objednávku a stůl
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public async Task <Tables> PutTask(Tables table)
        {
            OrderInfoServices orderInfoServices = new OrderInfoServices();



            IsBusy = true;
            Stolies.Clear();

            var result = await StolyDataService.UpdateItemAsync(table);


            Orders dataStore = new Orders()
            {
                tableId = table.id, startTime = DateTime.Now,
            };
            var s = await orderInfoServices.AddItemAsync(dataStore);

            table.orders = new ObservableCollection <Orders>();


            table.orders.Add(s);

            IsBusy = false;
            return(table);
        }
 public TableesViewModel()
 {
     Stolies          = new ObservableCollection <Models.Tables>();
     StolyDataService = new StolyDataService();
     PutItemsCommand  = new Xamarin.Forms.Command(async() => await PutTask(Stul));
     LoadItemsCommand = new Xamarin.Forms.Command(async() => await GetTask());
 }
        public async Task GetTask()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Stolies.Clear();
            var items = await StolyDataService.GetItemsAsync(true);

            try
            {
                foreach (var item in items)
                {
                    Stolies.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        /// <summary>
        /// Updatuje objednávku
        /// </summary>
        /// <returns></returns>

        /// <summary>
        /// Ukončí objednávku
        /// </summary>
        /// <returns></returns>
        public async Task EndOrder()
        {
            Table.isAvailable = true;//uvolni stůl
            var date = DateTime.UtcNow;

            Orders[0].endTime = date;//Ukonči objednávku a konvertuj do správného tvaru
            StolyDataService stolyDataService = new StolyDataService();
            await stolyDataService.UpdateItemAsync(Table);

            await OrderInfoServices.UpdateItemAsync(Orders[0]);
        }
 UpdateTableAsync(Tables tables)
 {
     if (IsBusy)
     {
         return;
     }
     try
     {
         await StolyDataService.UpdateItemAsync(tables);
     }
     finally
     {
         IsBusy = false;
     }
 }