public ObservableCollection<ItemModel> GetItemModelFrom( ICollection<Item> entities) { ObservableCollection<ItemModel> collection = new ObservableCollection<ItemModel>(); foreach (Item entity in entities) { ItemModel model = new ItemModel(entity); collection.Add(model); } return collection; }
private void AddItem() { using (AppContext context = new AppContext()) { var item = context.Items.Create(); item.Name = "<Enter Name>"; item.Description = "<Enter Description>"; item.Sku = "<Sku>"; context.Items.Add(item); context.SaveChanges(); var model = new ItemModel(item); Items.Add(model); SelectedItem = model; } }