async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { BusinessTrips.Clear(); var items = await BusinessTripDataStore.GetItemsAsync(true); foreach (var item in items) { BusinessTrips.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public BusinessTripOverviewViewModel() { Title = "CiuchApp - Wyjazdy"; BusinessTrips = new ObservableCollection <BusinessTrip>(); LoadBusinessTripsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <BusinessTripEditPage, BusinessTrip>(this, "Dodaj nowy", async(obj, item) => { var newItem = item as BusinessTrip; BusinessTrips.Add(newItem); await BusinessTripDataStore.AddItemAsync(newItem); }); }
internal async Task Save() { await BusinessTripDataStore.UpdateItemAsync(Model); }