Example #1
0
        private async Task ReloadFridgeItems()
        {
            FridgeItems.Clear();
            Fridge = await FridgeDataService.GetFridgeById(int.Parse(HouseholdId), int.Parse(FridgeId));

            FridgeItems.AddRange(Fridge.Items);
        }
Example #2
0
        public async void GetInventoryItems()
        {
            try
            {
                AllInventoryItems = await BackendConn.GetInventory();

                foreach (var inventoryItem in AllInventoryItems)
                {
                    switch (inventoryItem.InventoryType)
                    {
                    case 0:
                        FreezerItems.Add(inventoryItem.Item);
                        break;

                    case 1:
                        FridgeItems.Add(inventoryItem.Item);
                        break;

                    case 2:
                        PantryItems.Add(inventoryItem.Item);
                        break;

                    case 3:
                        ShoppingListItems.Add(inventoryItem.Item);
                        break;

                    default:
                        break;
                    }
                    AllItems.Add(inventoryItem.Item);
                    inventoryItem.Category = GetCategory(inventoryItem.InventoryType);
                }

                ViewFilter = (CollectionView)CollectionViewSource.GetDefaultView(AllInventoryItems);

                ViewFilter.Filter = UserFilter;
            }
            catch (ApiException exception)
            {
                ItemNotFound(exception.StatusCode);
            }
            catch (HttpRequestException exception)
            {
                MessageBox.Show($"Der er ingen forbindele til serveren", "Error!");
            }
            finally
            {
                RaisePropertyChanged("AllInventoryItems");
            }
        }
Example #3
0
        protected async Task DeleteFridgeItem(FridgeItem fridgeItem)
        {
            var wasRemoveSuccessful = await FridgeDataService.DeleteFridgeItem(Fridge.HouseholdId, Fridge.FridgeId, fridgeItem.FridgeItemId);

            if (wasRemoveSuccessful)
            {
                FridgeItems.Remove(fridgeItem);
                StateHasChanged();
                ToastService.ShowInfo($"Successfully removed {fridgeItem.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {fridgeItem.Name}", "Delete Failed");
            }
        }