Esempio n. 1
0
        public IEnumerable <DVD> GetByTitle(string title)
        {
            var repository = new DVDLibraryEntities();

            IEnumerable <DVD> model = repository.DVDs.Where(d => d.Title == title);


            return(model);
        }
Esempio n. 2
0
        public IEnumerable <DVD> GetByYear(string year)
        {
            var repository = new DVDLibraryEntities();

            IEnumerable <DVD> model = repository.DVDs.Where(d => d.RealeaseYear == year);


            return(model);
        }
Esempio n. 3
0
        public IEnumerable <DVD> GetByRating(string rating)
        {
            var repository = new DVDLibraryEntities();

            IEnumerable <DVD> model = repository.DVDs.Where(d => d.Rating == rating);


            return(model);
        }
Esempio n. 4
0
        public IEnumerable <DVD> GetByDirector(string director)
        {
            var repository = new DVDLibraryEntities();

            IEnumerable <DVD> model = repository.DVDs.Where(d => d.Director == director);


            return(model);
        }
Esempio n. 5
0
        public DVD GetById(int id)
        {
            var repository = new DVDLibraryEntities();

            DVD model = repository.DVDs.FirstOrDefault(d => d.DvdId == id);


            return(model);
        }
Esempio n. 6
0
        public DVD Create(DVD dvd)
        {
            var repository = new DVDLibraryEntities();

            DVD model = repository.DVDs.Add(dvd);

            repository.SaveChanges();

            return(model);
        }
Esempio n. 7
0
        public void Delete(int id)
        {
            var repository = new DVDLibraryEntities();

            DVD model = repository.DVDs.FirstOrDefault(d => d.DvdId == id);

            repository.DVDs.Remove(model);

            repository.SaveChanges();
        }
Esempio n. 8
0
        public void Update(DVD dvd)
        {
            using (var ctx = new DVDLibraryEntities())
            {
                var result = ctx.DVDs.SingleOrDefault(d => d.DvdId == dvd.DvdId);
                if (result != null)
                {
                    result.DvdId        = dvd.DvdId;
                    result.Title        = dvd.Title;
                    result.RealeaseYear = dvd.RealeaseYear;
                    result.Director     = dvd.Director;
                    result.Rating       = dvd.Rating;
                    result.Notes        = dvd.Notes;

                    ctx.SaveChanges();
                }
            }
        }
Esempio n. 9
0
        public IEnumerable <DVD> Get()
        {
            var repository = new DVDLibraryEntities();

            return(repository.DVDs);
        }