示例#1
0
        public void DvdDelete(int dvdId)
        {
            var repo = new DVDLibraryEntities1();

            repo.Dvds.Remove(repo.Dvds.Single(d => d.dvdId == dvdId));
            repo.SaveChanges();
        }
示例#2
0
        public void DvdEdit(int dvdId, Dvd dvd)
        {
            var repo = new DVDLibraryEntities1();

            repo.Dvds.Remove(repo.Dvds.Single(d => d.dvdId == dvdId));
            repo.Dvds.Add(dvd);
            repo.SaveChanges();
        }
示例#3
0
        public void DvdCreate(Dvd dvd)
        {
            var repo = new DVDLibraryEntities1();

            if (repo.Dvds.Any())
            {
                dvd.dvdId = repo.Dvds.Max(d => d.dvdId) + 1;
            }
            else
            {
                dvd.dvdId = 0;
            }
            repo.Dvds.Add(dvd);
            repo.SaveChanges();
        }