public void AddBook(string name)
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         Book book = new Book { BookName = name };
         entities.Books.AddObject(book);
         entities.SaveChanges();
     }
 }
Beispiel #2
0
 public void AddBook(string name)
 {
     using (SampleDbEntities entities = new SampleDbEntities())
     {
         Book book = new Book {
             BookName = name
         };
         entities.Books.AddObject(book);
         entities.SaveChanges();
     }
 }
Beispiel #3
0
        public void DeleteBook(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    entities.Books.DeleteObject(book);
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
Beispiel #4
0
        public void UpdateBook(string id, string name)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    book.BookName = name;
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
        public void DeleteBook(string id)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    entities.Books.DeleteObject(book);
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }
        public void UpdateBook(string id, string name)
        {
            try
            {
                int bookId = Convert.ToInt32(id);

                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    Book book = entities.Books.SingleOrDefault(b => b.ID == bookId);
                    book.BookName = name;
                    entities.SaveChanges();
                }
            }
            catch
            {
                throw new FaultException("Something went wrong");
            }
        }