Exemple #1
0
        public LogListModelResult GetPaged(LogListQuery listModel)
        {
            LogListModelResult result = new LogListModelResult();

            result.List = new List <Log>();

            string sql = "select * from Log where 1 = 1";

            if (string.IsNullOrEmpty(listModel.Order))
            {
                sql += " order by date desc, LogId asc";
            }
            else
            {
                sql += " " + listModel.Order;
            }

            DataTable dt = SQLiteHelper.ExecutePager(listModel.PageIndex, listModel.PageSize, sql, null);

            foreach (DataRow item in dt.Rows)
            {
                result.List.Add(RowToModel(item));
            }

            string countSql = "select count(1) from Log where 1 = 1";

            object countNum = SQLiteHelper.ExecuteScalar(countSql, null);

            result.TotalCount = Convert.ToInt32(countNum);

            return(result);
        }
Exemple #2
0
        public ActionResult List(int?page = 1)
        {
            LogListQuery query = new LogListQuery();

            query.PageIndex = Convert.ToInt32(page);
            query.PageSize  = 8;

            LogListModelResult result = _LogService.GetPaged(query);
            var pageList = new StaticPagedList <Log>(result.List, query.PageIndex, query.PageSize, result.TotalCount);

            return(View(pageList));
        }