Ejemplo n.º 1
0
        public ActionResult RequestBook(String bookId,String userId)
        {
            try
            {
                int userid = Convert.ToInt32(userId);
                int bookCode = Convert.ToInt32(bookId);
                Boolean sessionState = sessionObj.CheckSession(userid);

                if (sessionState)
                {
                    IUserService userService = new UserService();
                    User user = userService.GetUserById(userid);
                    IBookService bookService = new BookService();
                    Book book = bookService.GetById(bookCode);
                    Boolean status = bookService.BookRequest(book, user);

                    if (status)
                    {
                        return Content("Success");
                    }
                    return Content("Failed");
                }

                return View("Error");
            }

            catch (Exception e)
            {
                Console.WriteLine("Error");
                Console.Write(e.ToString());
                return View("Error");
            }
        }
Ejemplo n.º 2
0
        public Boolean Add(int bookid)
        {
            try
            {
                IBookService bookService = new BookService();
                Book book = bookService.GetById(bookid);

                var bookRequest = new BookRequest();
                bookRequest.Book = book;

                IList<BookRequest> bookRequestList = new List<BookRequest>();
                bookRequestList.Add(bookRequest);

                IBookRequestDal bookRequestDal = new BookRequestDal();
                Boolean status = bookRequestDal.Add(bookRequestList);
                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Error in BookRequestService, Add()");
                Console.Write(e.ToString());
                return false;
            }
        }
Ejemplo n.º 3
0
        //        [TestMethod]
        public void TestGetAllBooks()
        {
            IBookService bookservice = new BookService();

            Assert.IsNotNull(bookservice.GetAllBooks());

              //          Assert.IsInstanceOfType(bookservice.GetAllBooks());
        }
Ejemplo n.º 4
0
 public void TestBookSearch()
 {
     String searchString = "Abhishek";
     IBookService bookService = new BookService();
     IList<Book> returnedList = bookService.BookSearch(searchString);
     Book book = returnedList.FirstOrDefault();
     Console.Write(book.Price);
     Assert.IsNotNull(returnedList.FirstOrDefault());
 }
Ejemplo n.º 5
0
        //        [TestMethod]
        public void TestBookRequest()
        {
            IBookService bookService = new BookService();
            Book book = bookService.GetById(15);
            IUserService userService = new UserService();
            User user = userService.GetUserById(20);

            Boolean status = bookService.BookRequest(book, user);

            Assert.IsTrue(status);
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
        public ActionResult RequestBookPage(String id)
        {
            int code = Convert.ToInt32(id);
            ViewBag.id = code;
            Boolean sessionState = sessionObj.CheckSession(code);

            if (sessionState)
            {
                IBookService bookService = new BookService();
                IList<Book> books = bookService.GetAllBooks();
                return View(books);
            }
            return View("Error");
        }
Ejemplo n.º 8
0
        public ActionResult ViewBooksUser(String id)
        {
            try
            {
                int code = Convert.ToInt32(id);
                Boolean sessionState = sessionObj.CheckSession(code);

                if (sessionState)
                {
                    IBookService bookService = new BookService();
                    IList<Book> books = bookService.GetAllBooks();

                    return View(books);
                }
                return View("Error");
            }

            catch (Exception e)
            {
                Console.WriteLine("Error retrieving books");
                Console.Write(e.ToString());
                return View("Error");
            }
        }
Ejemplo n.º 9
0
 public ActionResult SearchBook(String userId , String searchString)
 {
     try
     {
         ViewBag.userId = userId;
         IBookService bookService = new BookService();
         IList<Book> bookList = bookService.BookSearch(searchString);
         return View(bookList);
     }
     catch (Exception e)
     {
         Console.WriteLine("SearchBook Error");
         Console.Write(e.ToString());
         return Content("Error");
     }
 }