private async Task UpdateCheckedTodoItem(Groceries item)
        {
            await _groceriesTable.UpdateAsync(item);

            _items.Remove(item);
            ListItems.Focus(FocusState.Unfocused);

            ButtonRefresh_Click(null, null);
        }
        private async Task ResolveConflict(Groceries localVersion, Groceries azuresVersion)
        {
            if(azuresVersion == null)
            {
                await _groceriesTable.DeleteAsync(localVersion);
                return;
            }
            
            localVersion.Version = azuresVersion.Version;
            
            // this way we have a number to add to , sign will be good
            int delta = localVersion.Quantity - localVersion.Before;
            localVersion.Quantity = azuresVersion.Quantity + delta;
            localVersion.Before = 0;

            if(localVersion.Quantity <= 0)
            {

            }

            await _groceriesTable.UpdateAsync(localVersion);
        }
 private async Task InsertTodoItem(Groceries todoItem)
 {
     await _groceriesTable.InsertAsync(todoItem);
     _items.Add(todoItem);
 }
        private async void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(TextInput.Text) && string.IsNullOrEmpty(QuantityInput.Text)) return;

            // If item exists, just change quantity
            var existingItem = await FindGroceryByName(TextInput.Text);
            if (existingItem != null)
            {
                try
                {
                    if(existingItem.Before == 0)
                    {
                        existingItem.Before = existingItem.Quantity;
                    }

                    var quantity = Convert.ToInt32(QuantityInput.Text);
                    existingItem.Quantity = quantity;
                }
                catch (Exception)
                {
                    QuantityInput.Text = existingItem.Quantity.ToString();
                    return;
                }

                if(existingItem.Quantity > 0)
                {
                    await UpdateCheckedTodoItem(existingItem);
                }
                else
                {
                    _items.Remove(existingItem);
                    await _groceriesTable.DeleteAsync(existingItem);
                }

                return;
            }

            try
            {
                var quantity = Convert.ToInt32(QuantityInput.Text);
                if (quantity <= 0) return;

                var todoItem = new Groceries {Id = Guid.NewGuid().ToString("N"), Name = TextInput.Text, Quantity = quantity, OwnerUserId = _user.UserId, Before = quantity};
                await InsertTodoItem(todoItem);
            }
            catch (Exception) {}
            finally
            {
                TextInput.Text = string.Empty;
                QuantityInput.Text = "0";
            }
        }