示例#1
0
        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();
            }
        }
示例#2
0
 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,
         });
     }
 }
示例#3
0
        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();
        }
示例#4
0
 public void AddVegetable(Vegetable v) => Vegetables.Add(v);