public QueryResult <User> GetUsers(PagedDataRequest requestInfo) { var query = _session.QueryOver <User>(); var totalItemCount = query.ToRowCountQuery().RowCount(); var startIndex = ResultsPagingUtility.CalculateStartIndex(requestInfo.PageNumber, requestInfo.PageSize); var users = query.Skip(startIndex).Take(requestInfo.PageSize).List(); var queryResult = new QueryResult <User>(users, totalItemCount, requestInfo.PageSize); return(queryResult); }
public QueryResult <Broker> GetBrokers(PagedDataRequest requestInfo) { var startIndex = ResultsPagingUtility.CalculateStartIndex(requestInfo.PageNumber, requestInfo.PageSize); var context = new InformingDBContext(); var query = context.Brokers; var totalItemCount = query.Count(); var brokers = query.Skip(startIndex).Take(requestInfo.PageSize).ToList(); var queryResult = new QueryResult <Broker>(brokers, totalItemCount, requestInfo.PageSize); return(queryResult); }
public QueryResult <Task> GetTasks(PagedDataRequest requestInfo) { using (TaskManagementDbContext context = new TaskManagementDbContext()) { var query = context.Tasks; // _session.QueryOver<Task>(); var totalItemCount = query.Count(); var startIndex = ResultsPagingUtility.CalculateStartIndex(requestInfo.PageNumber, requestInfo.PageSize); var tasks = query.Skip(startIndex).Take(requestInfo.PageSize).ToList(); var queryResult = new QueryResult <Task>(tasks, totalItemCount, requestInfo.PageSize); return(queryResult); } }
public QueryResult <Customer> FindAllCustomersPagedOf(int?pageNum = -1, int?pageSize = -1) { var query = Session.QueryOver <Customer>(); if (pageNum == -1 & pageSize == -1) { return(new QueryResult <Customer>(query? .List() .AsQueryable())); } return(new QueryResult <Customer>(query .Skip(ResultsPagingUtility.CalculateStartIndex((int)pageNum, (int)pageSize)) .Take((int)pageSize).List().AsQueryable(), query.ToRowCountQuery().RowCount(), (int)pageSize) ); }
public QueryResult <Store> FindAllCategoriesPagedOf(int?pageNum = -1, int?pageSize = -1) { var query = Session.QueryOver <Store>(); if (pageNum == -1 & pageSize == -1) { return(new QueryResult <Store>(query? .Where(e => e.IsActive) .List() .AsQueryable())); } return(new QueryResult <Store>(query .Where(e => e.IsActive) .Skip(ResultsPagingUtility.CalculateStartIndex((int)pageNum, (int)pageSize)) .Take((int)pageSize).List().AsQueryable(), query.ToRowCountQuery().RowCount(), (int)pageSize) ); }
public QueryResult <Role> FindAllActiveRolesPagedOf(int?pageNum, int?pageSize) { var query = Session.QueryOver <Role>(); if (pageNum == -1 & pageSize == -1) { return(new QueryResult <Role>(query? .Where(r => r.IsActive == true) .WhereNot(r => r.Name == "SU") .List().AsQueryable())); } return(new QueryResult <Role>(query .Where(r => r.IsActive == true) .WhereNot(r => r.Name == "SU") .Skip(ResultsPagingUtility.CalculateStartIndex((int)pageNum, (int)pageSize)) .Take((int)pageSize).List().AsQueryable(), query.ToRowCountQuery().RowCount(), (int)pageSize) ); }
public QueryResult <User> GetUsersPagedAsync(int?pageNum, int?pageSize) { var query = Session.QueryOver <User>(); if (pageNum == -1 & pageSize == -1) { return(new QueryResult <User>(query .WhereNot(u => u.Login == "*****@*****.**") .Where(u => u.IsActive == true) .List().AsQueryable())); } return(new QueryResult <User>(query .WhereNot(u => u.Login == "*****@*****.**") .Where(u => u.IsActive == true) .Skip(ResultsPagingUtility.CalculateStartIndex((int)pageNum, (int)pageSize)) .Take((int)pageSize).List().AsQueryable(), query.ToRowCountQuery().RowCount(), (int)pageSize) ); }
public void CalculateStartIndex_first_page() { Assert.AreEqual(0, ResultsPagingUtility.CalculateStartIndex(1, 50)); }
public void CalculateStartIndex_second_page() { const int pageSize = 50; Assert.AreEqual(pageSize, ResultsPagingUtility.CalculateStartIndex(2, pageSize)); }
public void CalculateStartIndex_invalid_pageSize() { ResultsPagingUtility.CalculateStartIndex(25, 0); }
public void CalculateStartIndex_invalid_pageNumber() { ResultsPagingUtility.CalculateStartIndex(0, 50); }