public Sapling UpdateSapling(Sapling saplingChanges) { var sapling = _context.Saplings.Attach(saplingChanges); sapling.State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(saplingChanges); }
public Sapling DeleteSapling(int id) { Sapling sapling = _saplingList.FirstOrDefault(s => s.Id == id); if (sapling != null) { _saplingList.Remove(sapling); } return(sapling); }
public Sapling DeleteSapling(int id) { Sapling sapling = _context.Saplings.Find(id); if (sapling != null) { _context.Saplings.Remove(sapling); _context.SaveChanges(); } return(sapling); }
public Sapling UpdateSapling(Sapling saplingChanges) { Sapling sapling = _saplingList.FirstOrDefault(s => s.Id == saplingChanges.Id); if (sapling != null) { sapling.Name = saplingChanges.Name; sapling.CultivarName = saplingChanges.CultivarName; sapling.SpeciesName = saplingChanges.SpeciesName; sapling.InitialPrice = saplingChanges.InitialPrice; } return(sapling); }
public Sapling AddSapling(Sapling sapling) { _context.Saplings.Add(sapling); _context.SaveChanges(); return(sapling); }
public Sapling AddSapling(Sapling sapling) { sapling.Id = _saplingList.Max(s => s.Id) + 1; _saplingList.Add(sapling); return(sapling); }