protected void UpdateViewModel(string name, SavedListConfig item) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); if (item == null) throw new ArgumentNullException("item"); var configs = EnsureConfigsTask().Get(); if (configs != null) { SavedListConfigViewModel vmdl = configs.Rw.SingleOrDefault(i => i.Object.Name == name && i.IsMyOwn); if (vmdl == null) { vmdl = ViewModelFactory.CreateViewModel<SavedListConfigViewModel.Factory>().Invoke(DataContext, this, item, true); configs.Rw.Add(vmdl); SelectedItem = vmdl; } else { vmdl.Object = item; } } }
public SavedListConfigViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, SavedListConfiguratorViewModel parent, SavedListConfig obj, bool isMyOwn) : base(appCtx, dataCtx, parent) { this._object = obj; this.IsMyOwn = isMyOwn; }
protected SavedListConfig ExtractItem(string name, SavedListConfigurationList obj) { var item = obj.Configs.FirstOrDefault(i => i.Name == name); if (item == null) { item = new SavedListConfig(); item.Name = name; obj.Configs.Add(item); } return item; }