コード例 #1
0
        static void Main(string[] args)
        {
            List <book> list = new historyDAO().getHistoryBook("abc");

            foreach (book b in list)
            {
                Console.WriteLine(b);
            }
            Console.ReadKey();
        }
コード例 #2
0
        // GET: Home
        public ActionResult Index()
        {
            int pageIndex = 1;

            // If user clicked on other page index
            if (Request.QueryString["pageIndex"] != null)
            {
                // Then pageIndex = value of that page index user clicked
                pageIndex = Int32.Parse(Request.QueryString["pageIndex"]);
            }
            int pageSize = 5;



            // Count all homes in database (Table Home)
            int totalPage = bd.countPage(pageSize);

            // IF count % pageSize == 0 => totalPage = count / pageSize


            // Display total of page to Home page for pagging
            ViewData["totalPage"] = totalPage;
            // Display pageIndex to active page current
            ViewData["pageIndex"] = pageIndex;

            // Display list of homes and list of places to Home page
            dynamic dy = new ExpandoObject(); // dynamic - multiple model

            dy.cates = cd.getAll();
            dy.books = bd.getAll(pageSize, pageIndex);

            //get history
            List <book> historyBook = new List <book>();

            if (Session["userName"] != null)
            {
                string username = (string)Session["userName"];
                historyBook = new historyDAO().getHistoryBook(username);
            }
            //dy.history = historyBook;
            Session["histories"] = historyBook;

            return(View(dy));
        }