Ejemplo n.º 1
0
        public void AddDVD(DVD ToAdd)
        {
            DVDLibraryEntities Libris = new DVDLibraryEntities();

            Libris.DVDs.Add(ToAdd);
            Libris.SaveChanges();
            Note ToAddNote = new Note
            {
                DVDID = (Libris.DVDs.Max(d => d.DVDID)),
                Notes = ToAdd.Note
            };

            Libris.Notes.Add(ToAddNote);
            Libris.SaveChanges();
        }
Ejemplo n.º 2
0
        public void DeleteDvD(int DVDID) //WORKS
        {
            DVDLibraryEntities Libris = new DVDLibraryEntities();

            var dvd = Libris.DVDs.Where(d => d.DVDID == DVDID).FirstOrDefault();

            if (dvd != null)
            {
                Libris.Notes.Remove(Libris.Notes.Where(d => d.DVDID == DVDID).FirstOrDefault());
                Libris.DVDs.Remove(Libris.DVDs.Where(d => d.DVDID == DVDID).FirstOrDefault());
                Libris.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void EditDVD(DVD ToEdit)
        {
            DVDLibraryEntities Libris = new DVDLibraryEntities();

            DVD dvd = new DVD();

            dvd.DVDID        = ToEdit.DVDID;
            dvd.Title        = ToEdit.Title;
            dvd.Director     = ToEdit.Director;
            dvd.RatingID     = ToEdit.RatingID;
            dvd.RatingName   = ToEdit.RatingName;
            dvd.realeaseYear = ToEdit.realeaseYear;
            Note noteedit = Libris.Notes.Where(n => n.DVDID == ToEdit.DVDID).FirstOrDefault();

            noteedit.Notes               = ToEdit.Note;
            Libris.Entry(dvd).State      = System.Data.Entity.EntityState.Modified;
            Libris.Entry(noteedit).State = System.Data.Entity.EntityState.Modified;
            Libris.SaveChanges();
        }