public void RemovePlant(int id)
        {
            var plantForRemoval = Plants.FirstOrDefault(p => p.Id == id);

            //var removalName = Plants.Find(p => )
            Plants.Remove(plantForRemoval);
            SaveChanges();
            Console.WriteLine($"I removed the {plantForRemoval.Species} and gave it to the groundhog to eat.");
        }
Exemple #2
0
        async Task DeletePlant(Plant plant)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (plant != null)
            {
                await App.PlantService.RemovePlantAsync(plant.Id);

                Plants.Remove(plant);
            }

            IsBusy = false;
        }
Exemple #3
0
        async Task UpdatePlant(object sender, Plant plant)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (plant != null)
            {
                await App.PlantService.UpdatePlantAsync(plant.Id, plant);

                var oldPlant = Plants.SingleOrDefault(x => x.Id == plant.Id);
                if (oldPlant != null)
                {
                    Plants.Remove(oldPlant);
                    Plants.Add(plant);
                }
            }

            IsBusy = false;
        }
Exemple #4
0
 public void RemovePlant(Plant item)
 {
     Plants.Remove(item);
 }
 public void DeletePlant(Plant plant10)
 {
     Plants.Remove(plant10);
     SaveChanges();
     Console.WriteLine("Plant " + plant10.PlantId + " Deleted");
 }