Exemple #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");
            }
        }
Exemple #2
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);
        }