public async Task <JqDataTableResponse <CustomerListItemDto> > GetPagedResultAsync(CustomerJqDataTableRequestModel model) { return(await _customerRepository.GetPagedResultAsync(model)); }
public async Task <JqDataTableResponse <CustomerListItemDto> > GetPagedResultAsync(CustomerJqDataTableRequestModel model) { if (model.Length == 0) { model.Length = Constants.DefaultPageSize; } var filerKey = model.Search.Value; var linqstmt = (from c in _dataContext.Customers where c.Status != Constants.RecordStatus.Deleted && (model.FilterKey == null || EF.Functions.Like(c.FirstName, "%" + model.FilterKey + "%") || EF.Functions.Like(c.LastName, "%" + model.FilterKey + "%") || EF.Functions.Like(c.Email, "%" + model.FilterKey + "%")) select new CustomerListItemDto { Id = c.Id, FirstName = c.FirstName, MiddleName = c.MiddleName, LastName = c.LastName, Phone = c.Phone, Email = c.Email, AccountNumber = c.AccountNumber, BankBranch = c.BankBranch, Discount = (c.Discount ?? 0), Status = c.Status }) .AsNoTracking(); var sortExpression = model.GetSortExpression(); var pagedResult = new JqDataTableResponse <CustomerListItemDto> { RecordsTotal = await _dataContext.Customers.CountAsync(x => x.Status != Constants.RecordStatus.Deleted), RecordsFiltered = await linqstmt.CountAsync(), Data = await linqstmt.OrderBy(sortExpression).Skip(model.Start).Take(model.Length).ToListAsync() }; return(pagedResult); }
public async Task <IActionResult> GetPagedResult(CustomerJqDataTableRequestModel model) { var pagedResult = await _customerManager.GetPagedResultAsync(model); return(Ok(pagedResult)); }