Ejemplo n.º 1
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);

            return(View(dy));
        }
Ejemplo n.º 2
0
        // GET: Detail
        public ActionResult Index()
        {
            string id_raw = Request.QueryString["bookid"];

            if (id_raw == null)
            {
                id_raw = Session["id"].ToString();
            }
            int id = Int32.Parse(id_raw);



            commentDAO     cbd      = new commentDAO();
            List <comment> comments = cbd.getbyBook(id);
            List <author>  authors  = new AuthorDAO().getAuthorByBookID(id);
            categoryDAO    cd       = new categoryDAO();
            BookDAO        db       = new BookDAO();
            int            count    = comments.Count;
            dynamic        dy       = new ExpandoObject();

            dy.book           = db.getOne(id);
            ViewData["count"] = count;
            dy.cates          = cd.getAll();
            dy.comments       = comments;
            dy.replys         = cbd.getReplys(id);
            dy.authors        = authors;
            Session.Remove("id");
            return(View(dy));
        }
        // GET: ProfileView
        public ActionResult Index()
        {
            account a  = (account)Session["user"];
            dynamic dy = new ExpandoObject();

            dy.acc = a;
            categoryDAO cd = new categoryDAO();

            dy.cates = cd.getAll();
            commentDAO     cbd      = new commentDAO();
            List <comment> co       = cbd.getbyUser(a.username);
            int            countcmt = co.Count;

            ViewData["countcmt"] = countcmt;
            ViewBag.notifi       = Session["noti"];
            Session.Remove("noti");
            return(View(dy));
        }
        // GET: Categories
        public ActionResult Index()
        {
            BookDAO     bd        = new BookDAO();
            categoryDAO cd        = new categoryDAO();
            int         cateid    = Int32.Parse(Request.QueryString["cateid"]);
            int         pageIndex = 1;

            if (Request.QueryString["pageIndex"] != null)
            {
                pageIndex = Int32.Parse(Request.QueryString["pageIndex"]);
            }
            int pageSize = 2;



            // Count all homes in database (Table Home)
            int total = bd.getbycid(cateid, 1, 1000).Count;
            // IF count % pageSize == 0 => totalPage = count / pageSize
            int totalPage = total / pageSize;

            if (total % pageSize != 0)
            {
                totalPage += 1;
            }

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

            ViewData["text"] = txt;
            // 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.getbycid(cateid, pageIndex, pageSize);


            return(View(dy));
        }
Ejemplo n.º 5
0
        // GET: Manage
        public ActionResult Index()
        {
            account a = (account)Session["user"];

            if (a != null)
            {
                if (a.Role)
                {
                    BookDAO                db         = new BookDAO();
                    accountDAO             adb        = new accountDAO();
                    categoryDAO            cdb        = new categoryDAO();
                    commentDAO             cd         = new commentDAO();
                    AuthorDAO              authorDAO  = new AuthorDAO();
                    List <author>          authors    = authorDAO.getAll();
                    List <book>            books      = db.getAll(1000, 1);
                    List <comment>         comments   = cd.getAll();
                    List <account>         accounts   = adb.getAll();
                    List <category>        categories = cdb.getAll();
                    List <book_categories> bcats      = cdb.getAllss();
                    dynamic                dy         = new ExpandoObject(); // dynamic - multiple model
                    dy.books           = books;
                    dy.cates           = categories;
                    dy.bcats           = bcats;
                    dy.comments        = comments;
                    dy.accounts        = accounts;
                    dy.authors         = authors;
                    ViewData["countb"] = db.getAll(1000, 1).Count;
                    ViewData["counta"] = accounts.Count;
                    ViewData["countc"] = comments.Count;
                    return(View(dy));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Login"));
            }
        }