public MainContext(DbContextOptions <MainContext> options) : base(options) { if (!Dishes.Any()) { Dishes.Add(new Dish() { Name = "Plate" }); Dishes.Add(new Dish() { Name = "Fork" }); Dishes.Add(new Dish() { Name = "Knife" }); SaveChanges(); } if (!Fruits.Any()) { Fruits.Add(new Fruit() { Name = "Apple" }); Fruits.Add(new Fruit() { Name = "Orange" }); Fruits.Add(new Fruit() { Name = "Kiwi" }); SaveChanges(); } if (!Vegetables.Any()) { Vegetables.Add(new Vegetable() { Name = "Cucumber" }); Vegetables.Add(new Vegetable() { Name = "Tomato" }); Vegetables.Add(new Vegetable() { Name = "Carrot" }); SaveChanges(); } }
private void ReloadVegetables(List <Vegetable> vegetables) { Vegetables.Clear(); foreach (var vegetable in vegetables.OrderBy(v => v.Description)) { Vegetables.Add(new VegetableItemViewModel { Description = vegetable.Description, VegetableId = vegetable.VegetableId, Price = vegetable.Price, Image = vegetable.Image, IsActive = vegetable.IsActive, LastPurchase = vegetable.LastPurchase, Observation = vegetable.Observation, }); } }
public void PopulateItems() { Vegetables.Add(new Vegetable { Name = "Yarrow", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Pumpkins", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Cabbage", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Spinach", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Wheat Grass", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Horse gram", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Chickpea", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Green bean", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Garlic", Category = "Bulb and Stem" }); Vegetables.Add(new Vegetable { Name = "Onion", Category = "Bulb and Stem" }); Vegetables.Add(new Vegetable { Name = "Nopal", Category = "Bulb and Stem" }); SortItems(); }
public void AddVegetable(Vegetable v) => Vegetables.Add(v);