Esempio n. 1
0
        public ActionResult AddBooks(Book book)
        {
            try
            {
                IBookService service = new BookService();
                book.ToBeIssued = book.Copies;
                Boolean status = service.SaveBooks(book);

                return Content(status.Equals(true) ? "Saved !" : "Error saving book. Please try after sometime");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in Book Controller");
                Console.Write(e.ToString());
                return View();
            }
        }
Esempio n. 2
0
        public void TestSave()
        {
            Dal<Book> dal = new Dal<Book>();
            Book book = new Book();

            book.Author = "Abhishek";
            book.Copies = 2;
            book.Description = "Nice book";
            book.Name = "New book";
            book.Price = 500;
            book.Publisher = "Mehta Publisher";

            IList<Book> books = new List<Book>();
            books.Add(book);

            Assert.IsTrue(dal.Save(books));
        }
Esempio n. 3
0
        public BookRequest GetByBook(Book book)
        {
            try
            {
                String query = "From BookRequest b where b.Book.Id=" + book.Id;

                IDal<BookRequest> bookRequest = new Dal<BookRequest>();
                IList<BookRequest> bookRequests = bookRequest.Read(query);

                BookRequest returnedBookRequest = bookRequests.FirstOrDefault();

                return returnedBookRequest;
            }

            catch (Exception e)
            {
                Console.WriteLine("Error in BookRequest Dal , GetByBook()");
                Console.Write(e.ToString());
                return null;
            }
        }
Esempio n. 4
0
        public Boolean BookRequest(Book book, User user)
        {
            try
            {
                IList<User> users = new List<User>();
                users.Add(user);
               //             book.Users = users;

                IList<Book> books = new List<Book>();
                books.Add(book);

                IBookDal bookdal = new BookDal();
                Boolean status = bookdal.SaveBooks(books);

                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Some sort of error in BookService, BookRequest()");
                Console.WriteLine(e.ToString());
                return false;
            }
        }
Esempio n. 5
0
        public bool SaveBooks(Book book)
        {
            try
            {
                IBookDal bookdal = new BookDal();
                IList<Book> books = new List<Book>();
                books.Add(book);
                Boolean status = bookdal.SaveBooks(books);
                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Book service crashed");
                Console.Write(e.ToString());
                return false;
            }
        }
Esempio n. 6
0
 public BookRequest()
 {
     Book = new Book();
     _users = new List<User>();
 }