예제 #1
0
        public Sapling UpdateSapling(Sapling saplingChanges)
        {
            var sapling = _context.Saplings.Attach(saplingChanges);

            sapling.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(saplingChanges);
        }
예제 #2
0
        public Sapling DeleteSapling(int id)
        {
            Sapling sapling = _saplingList.FirstOrDefault(s => s.Id == id);

            if (sapling != null)
            {
                _saplingList.Remove(sapling);
            }
            return(sapling);
        }
예제 #3
0
        public Sapling DeleteSapling(int id)
        {
            Sapling sapling = _context.Saplings.Find(id);

            if (sapling != null)
            {
                _context.Saplings.Remove(sapling);
                _context.SaveChanges();
            }
            return(sapling);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public Sapling AddSapling(Sapling sapling)
 {
     _context.Saplings.Add(sapling);
     _context.SaveChanges();
     return(sapling);
 }
예제 #6
0
 public Sapling AddSapling(Sapling sapling)
 {
     sapling.Id = _saplingList.Max(s => s.Id) + 1;
     _saplingList.Add(sapling);
     return(sapling);
 }