Exemplo n.º 1
0
        public ActionResult JsonSuccessGenericPageExecResult <T>(GenericPageResult <T> pageResult, string message = "")
        {
            GenericExecResult <GenericPageResult <T> > execResult = new GenericExecResult <GenericPageResult <T> >()
            {
                Success = true,
                Message = message,
                Data    = pageResult
            };

            return(ResponseJson(execResult));
        }
Exemplo n.º 2
0
        public GenericPageResult <T> Page <T>(IOrderByGetter orderByGetter, IWhereGetter where, int pageIndex = 1, int pageSize = 10)
            where T : class
        {
            var iCriteria = this.Session.CreateCriteria <T>();

            pageIndex = pageIndex == 0 ? 1 : pageIndex;
            iCriteria = QueryParameterHelper.Add(iCriteria, where);
            var total = ICriteriaHelper.Count(iCriteria);

            iCriteria.SetMaxResults(pageSize);
            iCriteria.SetFirstResult(pageSize * (pageIndex - 1));
            iCriteria = QueryParameterHelper.AddOrder(iCriteria, orderByGetter.OrderBys);
            var list = iCriteria.List <T>();
            GenericPageResult <T> resultData = new GenericPageResult <T>()
            {
                Data      = list,
                PageIndex = pageIndex,
                PageSize  = pageSize,
                Total     = total
            };

            return(resultData);
        }