public void Load(string file) { if (!IsLoaded) { LocalData.Clear(); var listItems = JsonConvert.DeserializeObject <List <GeneratorLocalData> >(Resources.Load <TextAsset>(file).text); listItems.ForEach(li => LocalData.Add(li.id, li)); listItems.ForEach(li => { //Debug.Log($"generator local data {li.id}, names count => {li.names.Count}"); }); IsLoaded = true; } }
public async Task SaveAllChanges() { List <BatchEditModel> deletedItems = LocalData.Where(itm => itm.IsDeleted == true).ToList(); List <BatchEditModel> newItems = LocalData.Where(itm => itm.IsNew == true).ToList(); List <BatchEditModel> updatedItems = LocalData.Where(itm => itm.IsChanged == true && itm.IsDeleted == false).ToList(); // clean up current data and selection LocalData.Clear(); SelectedItems = Enumerable.Empty <BatchEditModel>(); // update the grid with the data from the service List <BatchEditModel> newData = await theService.BatchUpdate(deletedItems, newItems, updatedItems); LocalData = new ObservableCollection <BatchEditModel>(newData); }