コード例 #1
0
        //Solo recibe objetos de la clase WaterVehicle
        public void SaveWaterPokemon(WaterPokemon waterPokemon)
        {
            var searchResult = WaterList.Where(p => p.Name == waterPokemon.Name).ToList();

            //if it didnt find any coincidence, then searchresult is null
            if (searchResult.Count() > 0)
            {
                throw new Exception("pokemon already stored");
            }
            else
            {
                //otherwise it stores the pokemon successfully
                WaterList.Add(waterPokemon);
            }
        }
コード例 #2
0
        public void AddedWater()
        {//add water amount to list
            WaterList.Add(new Water {
                WaterAdded = WaterAdded
            });
            MainView     = true;
            OpenAddWater = false;
            OnPropertyChanged("MainView");
            OnPropertyChanged("OpenAddWater");

            //add to water amount to water table in database
            var t = new Water()
            {
                WaterAdded = WaterAdded
            };

            context.WaterDrank.Add(t);
            context.SaveChanges();
        }