コード例 #1
0
        public LisOfDepositsForListVm GetAllDepositForList(int pageSize, int pageNo, string searchString, string searchStringOwnerName)
        {
            var countOfDeposits = _depositRepository.GetAllActiveDeposits().Count();
            var depositsToShow  = _depositRepository.GetAllActiveDeposits()
                                  .Where(p => p.Name.Contains(searchString))
                                  .Where(d => d.Owner.LastName.Contains(searchStringOwnerName) || d.Owner.FirstName.Contains(searchStringOwnerName))
                                  .ProjectTo <DepositForListVm>(_mapper.ConfigurationProvider)
                                  .Skip(pageSize * (pageNo - 1)).Take(pageSize).ToList();

            //var depositsToShow = deposits.Skip(pageSize * (pageNo - 1)).Take(pageSize).ToList();

            var depositList = new LisOfDepositsForListVm()
            {
                CurrentPage  = pageNo,
                PageSize     = pageSize,
                SearchString = searchString,
                Deposits     = depositsToShow,
                Count        = countOfDeposits
            };


            return(depositList);
        }