Exemplo n.º 1
0
 public List <AUTHOR> getAllAuthors()
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.AUTHORs.OrderBy(x => x.LastName).ToList());
     }
 }
Exemplo n.º 2
0
 public CLASSIFICATION Read(int signId)
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.CLASSIFICATIONs.Find(signId));
     }
 }
Exemplo n.º 3
0
        public void Update(BOOK bookObj)
        {
            using (var db = new swagbaseEntities1())
            {
                BOOK dummyBook = db.BOOKs.Include("AUTHORs").FirstOrDefault(a => a.ISBN == bookObj.ISBN);
                db.BOOKs.Attach(dummyBook);
                db.CLASSIFICATIONs.Attach(db.CLASSIFICATIONs.Find(bookObj.SignId));

                dummyBook.pages           = bookObj.pages;
                dummyBook.Title           = bookObj.Title;
                dummyBook.publicationinfo = bookObj.publicationinfo;
                dummyBook.PublicationYear = bookObj.PublicationYear;
                dummyBook.ISBN            = bookObj.ISBN;

                dummyBook.AUTHORs.Clear();
                List <int> authorsToDummy = bookObj.AUTHORs.Select(a => a.Aid).ToList();



                foreach (int auth in authorsToDummy)
                {
                    db.AUTHORs.Attach(db.AUTHORs.Find(auth));
                    dummyBook.AUTHORs.Add(db.AUTHORs.Find(auth));
                }
                dummyBook.pages           = bookObj.pages;
                dummyBook.Title           = bookObj.Title;
                dummyBook.publicationinfo = bookObj.publicationinfo;
                dummyBook.PublicationYear = bookObj.PublicationYear;
                dummyBook.SignId          = bookObj.SignId;
                //dummyBook.CLASSIFICATION = bookObj.CLASSIFICATION;

                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
 public List <AUTHOR> List()
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.AUTHORs.Include(x => x.BOOKs).ToList());
     }
 }
Exemplo n.º 5
0
 public List <AUTHOR> AuthorList(string isbn)
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.BOOKs.Include(x => x.AUTHORs).Include(x => x.CLASSIFICATION).Where(x => x.ISBN == isbn).First().AUTHORs.ToList());
     }
 }
Exemplo n.º 6
0
 public CLASSIFICATION getClassification(string isbn)
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.BOOKs.Include(x => x.AUTHORs).Include(x => x.CLASSIFICATION).Where(x => x.ISBN == isbn).First().CLASSIFICATION);
     }
 }
Exemplo n.º 7
0
 public List <BOOK> List()
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.BOOKs.Include(x => x.AUTHORs).Include(x => x.CLASSIFICATION).OrderBy(x => x.Title).ToList());
     }
 }
Exemplo n.º 8
0
 public List <CLASSIFICATION> List()
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.CLASSIFICATIONs.ToList());
     }
 }
Exemplo n.º 9
0
 public List <BOOK> getBookList(int aId)
 {
     using (var db = new swagbaseEntities1())
     {
         return(db.AUTHORs.Include(x => x.BOOKs).Where(x => x.Aid == aId).First().BOOKs.ToList());
     }
 }
Exemplo n.º 10
0
 public void Add(AUTHOR authorObj)
 {
     using (var db = new swagbaseEntities1())
     {
         db.AUTHORs.Add(authorObj);
         db.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public AUTHOR Read(int aID)
 {
     using (var db = new swagbaseEntities1())
     {
         db.Configuration.LazyLoadingEnabled = false;
         return(db.AUTHORs.Include(x => x.BOOKs).Where(x => x.Aid == aID).First());
     }
 }
Exemplo n.º 12
0
 public void Add(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         db.CLASSIFICATIONs.Add(classiObj);
         db.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public BOOK Read(string isbn)
 {
     using (var db = new swagbaseEntities1())
     {
         db.Configuration.LazyLoadingEnabled = false;
         return(db.BOOKs.Include(x => x.AUTHORs).Include(x => x.CLASSIFICATION).Where(x => x.ISBN == isbn).First());
     }
 }
Exemplo n.º 14
0
 public void Delete(AUTHOR authorObj)
 {
     using (var db = new swagbaseEntities1())
     {
         AUTHOR athID = db.AUTHORs.Find(authorObj.Aid);
         db.AUTHORs.Remove(athID);
         db.SaveChanges();
     }
 }
Exemplo n.º 15
0
 public void Delete(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         CLASSIFICATION csignID = db.CLASSIFICATIONs.Find(classiObj.SignId);
         db.CLASSIFICATIONs.Remove(csignID);
         db.SaveChanges();
     }
 }
Exemplo n.º 16
0
 public void Delete(BOOK bookObj)
 {
     using (var db = new swagbaseEntities1())
     {
         BOOK bISBN = db.BOOKs.Find(bookObj.ISBN);
         db.BOOKs.Remove(bISBN);
         db.SaveChanges();
     }
 }
Exemplo n.º 17
0
 public void Update(CLASSIFICATION classiObj)
 {
     using (var db = new swagbaseEntities1())
     {
         db.CLASSIFICATIONs.Attach(classiObj);
         db.Entry(classiObj).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 18
0
        public void Update(AUTHOR authorObj)
        {
            using (var db = new swagbaseEntities1())
            {
                AUTHOR dummyAuthor = db.AUTHORs.Include("BOOKs").FirstOrDefault(a => a.Aid == authorObj.Aid);

                db.AUTHORs.Attach(dummyAuthor);
                dummyAuthor.BirthYear = authorObj.BirthYear;
                dummyAuthor.FirstName = authorObj.FirstName;
                dummyAuthor.LastName  = authorObj.LastName;

                //dummyAuthor.BOOKs.Clear();
                //AUTHOR booksToDummy = authorObj.BOOKs.Select


                db.Entry(dummyAuthor).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Exemplo n.º 19
0
        public void Add(BOOK bookObj)
        {
            using (var db = new swagbaseEntities1())
            {
                List <AUTHOR> auths = bookObj.AUTHORs.ToList();


                bookObj.AUTHORs        = null;
                bookObj.CLASSIFICATION = null;

                db.BOOKs.Add(bookObj);


                foreach (AUTHOR a in auths)
                {
                    db.AUTHORs.Attach(a);
                    a.BOOKs.Add(bookObj);
                    db.Entry(a).State = EntityState.Modified;
                }

                db.SaveChanges();
            }
        }