Example #1
0
        static void Main(string[] args)
        {
            Book b = new Book();

            while (true)
            {
                int choice = b.menu();
                switch (choice)
                {
                case 1:
                    b.AddNewBook();
                    break;

                case 2:
                    b.UpdateBook();
                    break;

                case 3:
                    b.DeleteBook();
                    break;

                case 4:
                    b.DisplayBooks();
                    break;

                case 5:
                    return;
                }
            }
        }
Example #2
0
        public void CreateLargeBook()
        {
            Author a     = new Author("Rasmus", "Öjebro");
            string title = "Rasmus Test Bok";
            int    pages = 10000;

            Book.AddNewBook(a, title, pages);
            Book b = Book.Books.Last();

            Assert.AreEqual("large", b.Type, "New large book has type: {0}", b.Type);
        }
Example #3
0
        public void CreateMediumBook()
        {
            Author a     = new Author("Rasmus", "Öjebro");
            string title = "Rasmus Test Bok";
            int    pages = 584;

            Book.AddNewBook(a, title, pages);
            Book b = Book.Books.Last();

            Assert.AreEqual("medium", b.Type, "New medium book has type: {0}", b.Type);
        }
Example #4
0
        public void CreateSmallBook()
        {
            Author a     = new Author("Rasmus", "Öjebro");
            string title = "Rasmus Test Bok";
            int    pages = 249;

            Book.AddNewBook(a, title, pages);
            Book b = Book.Books.Last();

            Assert.AreEqual("small", b.Type, "New small book has type: {0}", b.Type);
        }
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            if (ValidateInputs() == false)
            {
                return;
            }
            Book newBook = new Book(txtISBN.Text, txtBookTitle.Text, int.Parse(lstAuthor.SelectedValue.ToString()), double.Parse(txtPrice.Text),
                                    txtRackNo.Text, int.Parse(txtCopies.Text), 0, int.Parse(System.Environment.GetEnvironmentVariable("librarianID")));

            int recordAdded = newBook.AddNewBook();

            if (recordAdded != 0)
            {
                MessageBox.Show("Book inserted successfully.");
                ClearTextBoxes();
            }
            else
            {
                MessageBox.Show("Insertion Operation failed. Check the values provided and try again.");
            }
        }
Example #6
0
 public string JSONData(string id)
 {
     Book knjiga = new Book("Knjiga test", "Desa", 1990, "sloven", "poezi", "dostopno na spletu");
     string ret = "";
     if (id == "DODAJ")
     {
         ret = knjiga.AddNewBook();
     }
     else if (id == "UREDI")
     {
         ret = knjiga.Update("Knjiga test", "Desa", 2000, "sloven", "poezi", "dostopno na spletu");
     }
     else if(id=="IZPIS")
     {
         ret = knjiga.ToString();
     }
     else if(id=="DELETE")
     {
         ret = knjiga.Delete(5);
     }
     return ret;
 }
Example #7
0
        public Book JSONData(string id,string naslov, string avtor, string gradivo, string leto, string jezik, string zalozba)
        {
            Book knjiga = new Book(naslov, avtor, leto, jezik, gradivo, zalozba);
            string ret = "";
            if (id == "DODAJ")
            {
                ret = knjiga.AddNewBook();
            }
            else if (id == "UREDI")
            {
                ret = knjiga.Update(naslov, avtor, leto, jezik, gradivo, zalozba);
            }
            else if (id == "IZPIS")
            {
                ret = knjiga.ToString();
            }
            else if (id == "DELETE")
            {
                ret = knjiga.Delete(5);
            }

            return knjiga;
        }
Example #8
0
 public IHttpActionResult AddNewBook(Book newBook)
 {
     Book.AddNewBook(newBook, Setting.PathToLibraryDatabase);
     return(Ok("The book was successfully added."));
 }