public async Task <IPagedResult <Customer> > ListAsync(int pageIndex, int pageSize, string term = null, long?userId = null) { var filterSpecification = new CustomerFilterSpecification( userId: userId, term: term ); var filterPaginatedSpecification = new CustomerFilterPaginatedSpecification(pageIndex * pageSize, pageSize, userId: userId, term: term ); var items = await _customerRepository.ListAsync(filterPaginatedSpecification); var totalItems = await _customerRepository.CountAsync(filterSpecification); return(new PagedResult <Customer>(pageIndex, pageSize, totalItems, items)); }
public async Task <PaginationViewModel <CustomerViewModel> > GetItemsAsync(string openId, string name, int skipCount = 0, int takeCount = 0) { var filterPaginatedSpecification = new CustomerFilterPaginatedSpecification(name, openId, skipCount, takeCount); var result = new PaginationViewModel <CustomerViewModel>() { rows = (await _customerRepository.ListAsync(filterPaginatedSpecification)).Select(item => new CustomerViewModel() { OpenId = item.OpenId, NickName = item.NickName, AvatarUrl = item.AvatarUrl, City = item.City, Country = item.Country, Gender = item.Gender, LastLoginTime = item.LastLoginTime, Province = item.Province, }).OrderByDescending(item => item.LastLoginTime).ToList(), total = await _customerRepository.CountAsync(filterPaginatedSpecification) }; return(result); }