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."); }
async Task DeletePlant(Plant plant) { if (IsBusy) { return; } IsBusy = true; if (plant != null) { await App.PlantService.RemovePlantAsync(plant.Id); Plants.Remove(plant); } IsBusy = false; }
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; }
public void RemovePlant(Plant item) { Plants.Remove(item); }
public void DeletePlant(Plant plant10) { Plants.Remove(plant10); SaveChanges(); Console.WriteLine("Plant " + plant10.PlantId + " Deleted"); }