public DetailPageViewModel Filter(FilterDebsViewModel model, int page) { DetailPageViewModel result = new DetailPageViewModel(); try { DateTime from = DateTime.Parse(model.From); DateTime to = Convert.ToDateTime(model.To); int pageToQuantity = 10; result.Account = _dbContext.Accounts .Include(x => x.Client) .Single(x => x.Id == model.IdAccount); result.Account.Debs = _dbContext.Debs .Where(x => x.AccountId == model.IdAccount && (x.DateTime >= from) && (x.DateTime <= to)) .OrderByDescending(x => x.DateTime) .Skip((page - 1) * pageToQuantity) .Take(pageToQuantity).ToList(); result.TotalOfRegister = _dbContext.Debs.Count(x => x.AccountId == model.IdAccount && (x.DateTime >= from) && (x.DateTime <= to)); result.ActuallyPage = page; result.RegisterByPage = pageToQuantity; } catch (Exception) { result = null; } return(result); }
public ActionResult Filter(FilterDebsViewModel vm, int page = 1) { var model = _debService.Filter(vm, page); if (model != null) { ViewBag.pagination = "1"; ViewBag.paramOne = vm.From; ViewBag.paramTwo = vm.To; ViewBag.other = vm.IdAccount; return(View("Detail", model)); } return(View("Detail", _repository.GetWithClientAndDebs(vm.IdAccount))); }