public async Task <bool> AddAsync(Character data) { Dataset.Add(data); var myReturn = await DataStore.AddAsync_Character(data); return(myReturn); }
public CharactersViewModel() { Title = "Character List"; Dataset = new ObservableCollection <Character>(); LoadDataCommand = new Command(async() => await ExecuteLoadDataCommand()); MessagingCenter.Subscribe <CharacterDeletePage, Character>(this, "DeleteData", async(obj, data) => { Dataset.Remove(data); await DataStore.DeleteAsync_Character(data); }); MessagingCenter.Subscribe <CharacterNewPage, Character>(this, "AddData", async(obj, data) => { Dataset.Add(data); await DataStore.AddAsync_Character(data); }); MessagingCenter.Subscribe <CharacterEditPage, Character>(this, "EditData", async(obj, data) => { // Find the Item, then update it var myData = Dataset.FirstOrDefault(arg => arg.Id == data.Id); if (myData == null) { return; } myData.Update(data); await DataStore.UpdateAsync_Character(data); _needsRefresh = true; }); }
private async Task <bool> AddCharacter(Character data) { Dataset.Add(data); return(await DataStore.AddAsync_Character(data)); }