protected async Task DeleteHousehold(Household household) { var deleteSuccessful = await HouseholdDataService.DeleteHousehold(household.HouseholdId); if (deleteSuccessful) { await RemoveFromRecentList(household); } }
protected override async Task OnInitializedAsync() { Household = await HouseholdDataService.GetHouseholdById(int.Parse(HouseholdId)); Fridges.AddRange(Household.Fridges); IsOffline = !FrinfoHttpClient.IsOnline; EventAggregator.SubscribeOnPublishedThread(this); }
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(); }
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}"); } }
protected async Task EditHousehold_OnClose() { Household = await HouseholdDataService.GetHouseholdById(int.Parse(HouseholdId)); StateHasChanged(); }