Пример #1
0
        public ActionResult AccountBookChildAction(int?year, int?month, int?page)
        {
            ViewBag.year  = year.HasValue ? year : null;
            ViewBag.month = month.HasValue ? month : null;

            IEnumerable <AccountBookViewModels> accountBookViewModels = Enumerable.Empty <AccountBookViewModels>();

            if (year.HasValue && month.HasValue)
            {
                accountBookViewModels = _accountBookSvc.LookupByYearMonth(year, month);
            }
            else if (year.HasValue && !month.HasValue)
            {
                accountBookViewModels = _accountBookSvc.LookupByYear(year);
            }
            else
            {
                accountBookViewModels = _accountBookSvc.Lookup();
            }

            var pageIndex = page.HasValue ? page.Value < 1 ? 1 : page.Value : 1;
            var pageSize  = 10;

            return(View(accountBookViewModels.OrderByDescending(x => x.Date).ToPagedList(pageIndex, pageSize)));

            //var source = _accountBookSvc.Lookup();
            //return View(source.OrderByDescending(x => x.Date).ToList());
            //return View(db.AccountBook.Take(10).OrderByDescending(x => x.Date).ToList());
        }