//delete a fenotype multi of the selected plant(Jim) public void RemoveMultiPhenotype(FenotypeMulti phenotypeMulti) { var selectedPhenotypeMulti = _context.FenotypeMulti.FirstOrDefault(i => i.Id == phenotypeMulti.Id); _context.Remove(phenotypeMulti); _context.SaveChanges(); }
//change the multi fenotype of the selected plant (Jim) public void ChangeMultiPhenotype(FenotypeMulti phenotypeMulti, string property, string month, string value) { var selectedPhenotypeMulti = _context.FenotypeMulti.FirstOrDefault(i => i.Id == phenotypeMulti.Id); selectedPhenotypeMulti.Eigenschap = property ?? selectedPhenotypeMulti.Eigenschap; selectedPhenotypeMulti.Maand = month ?? selectedPhenotypeMulti.Maand; selectedPhenotypeMulti.Waarde = value ?? selectedPhenotypeMulti.Waarde; _context.SaveChanges(); }
//delete the fenotype of the selected plant (Jim) /* public void DeleteFenotype(Fenotype fenotype) * { * var selectedfenotype = _context.Fenotype.FirstOrDefault(i => i.Id == fenotype.Id); * * _context.Fenotype.Remove(selectedfenotype); * _context.SaveChanges(); * } */ //add a multi fenotype to the selected plant (Jim) public void AddMultiPhenotype(Plant plant, string property, string month, string value) { if (_context.FenotypeMulti .FirstOrDefault(fm => fm.Eigenschap == property && fm.Maand == month && fm.Waarde == value && fm.PlantId == plant.PlantId) is not null) { return; } var phenotypeMultiPlant = new FenotypeMulti { Id = GetLastPhenoMultiId(), PlantId = plant.PlantId, Eigenschap = property, Maand = month, Waarde = value }; _context.FenotypeMulti.Add(phenotypeMultiPlant); _context.SaveChanges(); }