Esempio n. 1
0
        protected async Task DeleteHousehold(Household household)
        {
            var deleteSuccessful = await HouseholdDataService.DeleteHousehold(household.HouseholdId);

            if (deleteSuccessful)
            {
                await RemoveFromRecentList(household);
            }
        }
Esempio n. 2
0
        protected override async Task OnInitializedAsync()
        {
            Household = await HouseholdDataService.GetHouseholdById(int.Parse(HouseholdId));

            Fridges.AddRange(Household.Fridges);

            IsOffline = !FrinfoHttpClient.IsOnline;

            EventAggregator.SubscribeOnPublishedThread(this);
        }
Esempio n. 3
0
        protected async Task OnRemoveHousehold()
        {
            var removeSuccessful = await HouseholdDataService.DeleteHousehold(Household.HouseholdId);

            if (removeSuccessful)
            {
                NavigationManager.NavigateTo("/");
                ToastService.ShowInfo($"Successfully removed {Household.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {Household.Name}", "Delete failed");
            }
        }
        protected async Task AddHousehold()
        {
            if (Household.HouseholdId == 0)
            {
                Household = await HouseholdDataService.AddNewHousehold(Household.Name);
            }
            else
            {
                await HouseholdDataService.UpdateHousehold(Household);
            }

            ShowDialog = false;
            await CloseEventCallback.InvokeAsync(true);

            StateHasChanged();
        }
Esempio n. 5
0
        protected async Task OnSearchForCode()
        {
            var alreadyAddedHousehold = RecentHouseholds.FirstOrDefault(h => h.HouseholdCode == HouseholdCode);

            if (alreadyAddedHousehold != null)
            {
                NavigateToHousehold(alreadyAddedHousehold.HouseholdId);
            }

            var household = await HouseholdDataService.GetHouseholdByCode(HouseholdCode);

            var searchSuccessful = household != null;

            if (searchSuccessful)
            {
                RecentHouseholds.Insert(0, household);
                NavigateToHousehold(household.HouseholdId);
            }
            else
            {
                ToastService.ShowError($"Could not find any household with code {HouseholdCode}");
            }
        }
Esempio n. 6
0
        protected async Task EditHousehold_OnClose()
        {
            Household = await HouseholdDataService.GetHouseholdById(int.Parse(HouseholdId));

            StateHasChanged();
        }