本文整理汇总了C#中PagedList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PagedList.Add方法的具体用法?C# PagedList.Add怎么用?C# PagedList.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PagedList
的用法示例。
在下文中一共展示了PagedList.Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindEnties
/// <summary>
/// Find Enties
/// </summary>
/// <param name="pageIndex">pageIndex</param>
/// <param name="pageSize">pageSize</param>
/// <returns>Enties</returns>
public PagedList<EmployeePayHistoryDto> FindEnties(int? pageIndex, int pageSize)
{
var entities=entiesrepository.Repository.Find(p => p.EmployeeID!=null, p => p.EmployeeID, pageIndex, pageSize);
var listDtos=new PagedList<EmployeePayHistoryDto>() { TotalCount = entities.TotalCount };
entities.ForEach(entity => { listDtos.Add(typeAdapter.ConvertEntitiesToDto(entity)); });
return listDtos;
}
示例2: FindEntiesAsync
/// <summary>
/// Find Enties Async
/// </summary>
/// <param name="pageIndex">pageIndex</param>
/// <param name="pageSize">pageSize</param>
/// <returns>Enties</returns>
public async Task<PagedList<EmployeePayHistoryDto>> FindEntiesAsync(int? pageIndex, int pageSize)
{
var entities = await entiesrepository.Repository.FindAsync(p => p.EmployeeID!=null, p => p.EmployeeID, pageIndex, pageSize);
var listDtos = new PagedList<EmployeePayHistoryDto>() { TotalCount = entities.TotalCount, PageIndex=pageIndex.Value,PageSize=pageSize };
entities.ForEach(entity => { listDtos.Add(typeAdapter.ConvertEntitiesToDto(entity)); });
return listDtos;
}
示例3: MangaViewModel
/// <summary>
/// Creates a new MangaViewModel
/// </summary>
/// <param name="manga">Manga</param>
/// <param name="item_height"></param>
/// <param name="speed"></param>
public MangaViewModel(Manga manga, int item_height, decimal speed)
{
item_height_ = item_height;
speed_ = speed;
manga_ = manga;
slides_ = new PagedList<SlideViewModel>();
int item = 0;
foreach (var slide in manga_.Slides)
{
int page = item / kItemsPerPage;
item++;
slides_.Add(page, new SlideViewModel(slide, item_height_));
}
slides_.Update(0);
}
示例4: ListConfiguredProducts
/// <summary>
/// Fetch the list of products as configured on the backoffice. Note that this doesn't include any information
/// about pricing and so on: the external store plugin is required to do so.
/// Note that this call returns the catalog as configured on the CotC server, which may not be exhaustive if
/// additional products are configured on iTunes Connect but not reported to the CotC servers.
/// </summary>
/// <param name="limit">The maximum number of results to return per page.</param>
/// <param name="offset">Number of the first result.</param>
/// <returns>Promise resolved when the operation has completed. The attached value describes a list of products,
/// with pagination functionality.</returns>
public Promise<PagedList<ConfiguredProduct>> ListConfiguredProducts(int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v1/gamer/store/products").QueryParam("limit", limit).QueryParam("skip", offset);
return Common.RunInTask<PagedList<ConfiguredProduct>>(Gamer.MakeHttpRequest(url), (response, task) => {
PagedList<ConfiguredProduct> products = new PagedList<ConfiguredProduct>(response.BodyJson, offset, response.BodyJson["count"]);
foreach (Bundle b in response.BodyJson["products"].AsArray()) {
products.Add(new ConfiguredProduct(b));
}
// Handle pagination
if (offset > 0) {
products.Previous = () => ListConfiguredProducts(limit, offset - limit);
}
if (offset + products.Count < products.Total) {
products.Next = () => ListConfiguredProducts(limit, offset + limit);
}
task.PostResult(products);
});
}
示例5: ListUsers
/// <summary>
/// Method used to check or retrieve users from Clan of the Cloud community. The domain is not taken
/// in account for this search.
/// </summary>
/// <returns>Task returning the fetched list of users. The list is paginated (see
/// #CotcSdk.PagedList<DataType> for more info).</returns>
/// <param name="filter">May contain a nickname, a display name or e-mail address.</param>
/// <param name="limit">The maximum number of results to return per page.</param>
/// <param name="offset">Number of the first result.</param>
public Promise<PagedList<UserInfo>> ListUsers(string filter, int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v1/gamer").QueryParam("q", filter).QueryParam("limit", limit).QueryParam("skip", offset);
HttpRequest req = MakeUnauthenticatedHttpRequest(url);
return Common.RunInTask<PagedList<UserInfo>>(req, (response, task) => {
PagedList<UserInfo> result = new PagedList<UserInfo>(response.BodyJson, offset, response.BodyJson["count"]);
foreach (Bundle u in response.BodyJson["result"].AsArray()) {
result.Add(new UserInfo(u));
}
// Handle pagination
if (offset > 0) {
result.Previous = () => ListUsers(filter, limit, offset - limit);
}
if (offset + result.Count < result.Total) {
result.Next = () => ListUsers(filter, limit, offset + limit);
}
task.PostResult(result);
});
}
示例6: History
/// <summary>
/// Fetches the history of transactions run for this user. The current balance (resulting values) needs to be queried
/// via a different call (Balance).
/// </summary>
/// <returns>Promise resolved when the operation has completed. The result is paginated, for more information see
/// #CotcSdk.PagedList<DataType>.</returns>
/// <param name="unit">If specified, retrieves only the transactions matching a given unit (e.g. "gold").</param>
/// <param name="limit">For pagination, allows to set a greater or smaller page size than the default 30.</param>
/// <param name="offset">For pagination, avoid using it explicitly.</param>
public Promise<PagedList<Transaction>> History(string unit = null, int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v1/gamer/tx").Path(domain).QueryParam("skip", offset).QueryParam("limit", limit);
if (unit != null) url.QueryParam("unit", unit);
// Request for current results
return Common.RunInTask<PagedList<Transaction>>(Gamer.MakeHttpRequest(url), (response, task) => {
PagedList<Transaction> transactions = new PagedList<Transaction>(response.BodyJson, offset, response.BodyJson["count"]);
foreach (Bundle b in response.BodyJson["history"].AsArray()) {
transactions.Add(new Transaction(b));
}
// Handle pagination
if (offset > 0) {
transactions.Previous = () => History(unit, limit, offset - limit);
}
if (offset + transactions.Count < transactions.Total) {
transactions.Next = () => History(unit, limit, offset + limit);
}
task.PostResult(transactions);
});
}
示例7: FetchAvailablePublishedProcesses
public IPagedList<PublishedProcessInfoDTO> FetchAvailablePublishedProcesses(string filter, int pageNumber, int pageSize, string filterExpression, bool isAdmin, IEnumerable<int> personRoles)
{
var result = new PagedList<PublishedProcessInfoDTO>();
var roles = new List<int> { Constants.AllRolesId };
if (personRoles != null)
{
roles.AddRange(personRoles);
}
var rolesString = string.Join(",", roles.Select(r => r.ToString(CultureInfo.InvariantCulture)));
var adminFilter = string.Format(
CultureInfo.InvariantCulture,
@"WHERE ISNULL(p.[IsRemoved], 0) = 0 AND ISNULL(p.IsInactive, 0) = 0");
const string NonAdminFilterFormat = @"
WHERE
(
EXISTS
(
SELECT nisc.[Id]
FROM [dbo].[NavigationItemSecurityConfigurations] nisc
WHERE nisc.[NavigationItemId] = ni.Id AND nisc.[CanView] = 1 AND nisc.[RoleId] IN ({0})
)
AND
ISNULL(p.[IsRemoved], 0) = 0 AND ISNULL(p.IsInactive, 0) = 0
)
OR
ng.[SystemName] = '{1}'
";
var nonAdminFilter = string.Format(
CultureInfo.InvariantCulture,
NonAdminFilterFormat,
rolesString,
Constants.AdminMenu);
var whereString = isAdmin ? adminFilter : nonAdminFilter;
const string IdsQueryFormat = @"
SELECT
pp.[ProcessId]
FROM
[dbo].[NavigationGroups] ng
INNER JOIN [dbo].[NavigationItems] ni
ON ng.[Id] = ni.[NavigationGroupId]
INNER JOIN [dbo].[PublishedProcesses] pp
ON pp.[Id] = ni.[PublishedProcessId]
INNER JOIN [dbo].[Processes] p
ON p.[Id] = pp.[ProcessId]
{0}";
var idsQuery = string.Format(
CultureInfo.InvariantCulture,
IdsQueryFormat,
whereString);
using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
{
var cn = ctx.Connection;
const string Sql =
@"
DECLARE @p0 AS INT
SET @p0 = {1}
DECLARE @p1 AS INT
SET @p1 = {2};
SELECT [t1].[Id],
[t1].[Name],
[t1].[SystemName],
[t1].[IconId],
[t1].[Guid]
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY [t0].[Name], [t0].[Id]) AS
[ROW_NUMBER],
ISNULL(pl.ProcessName,[t0].[Name]) AS [Name],
[t0].SystemName,
[t0].[Guid],
[t0].Id,
[i].Id as IconId
FROM [dbo].[Processes] AS [t0]
JOIN [dbo].PublishedProcesses AS [t1] ON [t1].ProcessId = [t0].Id
INNER JOIN Processes p2 ON [t0].Guid = p2.Guid AND p2.IsPublishedCopy = 0
LEFT OUTER JOIN Icons i ON [t0].IconId = [i].Id
LEFT OUTER JOIN Colors c ON [t0].ColorId = [c].Id
LEFT OUTER JOIN dbo.Localizations l ON l.CultureName = '{3}'
LEFT OUTER JOIN dbo.ProcessLocalizations pl ON pl.LocalizationId = l.Id AND p2.Id = pl.ProcessId
{0}
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY
[t1].[ROW_NUMBER]
";
var fieldFilterWhere = AdoHelper.BuildFilterStatement(FilterDescriptor.GetFilterList(filterExpression), "Processes", tableAlias: "[t0]");
var globalFilterWhere = AdoHelper.BuildFilterStatement(filter, new[] { "[t0].Name" });
var where = string.Format(CultureInfo.InvariantCulture, "WHERE [t0].IsRemoved = 0 {0} {1} AND [t1].[ProcessId] IN ({2})", globalFilterWhere, fieldFilterWhere, idsQuery);
if (pageSize == 0)
{
//.........这里部分代码省略.........
示例8: FetchPublishedProcesses
public IPagedList<PublishedProcessInfoDTO> FetchPublishedProcesses(string filter, int pageNumber, int pageSize, string filterExpression)
{
var result = new PagedList<PublishedProcessInfoDTO>();
using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
{
var cn = ctx.Connection;
const string Sql = @"
DECLARE @p0 AS INT
SET @p0 = {1}
DECLARE @p1 AS INT
SET @p1 = {2};
SELECT [t1].[Id],
[t1].[Name],
[t1].[SystemName],
[t1].[IconId],
[t1].[Guid]
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY [t0].[Name], [t0].[Id]) AS
[ROW_NUMBER],
[t0].[Name],
[t0].SystemName,
[t0].[Guid],
[t0].Id,
[i].Id as IconId
FROM [dbo].[Processes] AS [t0]
JOIN [dbo].PublishedProcesses AS [t1] ON [t1].ProcessId = [t0].Id
LEFT OUTER JOIN Icons i ON [t0].IconId = [i].Id
LEFT OUTER JOIN Colors c ON [t0].ColorId = [c].Id
{0}
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY
[t1].[ROW_NUMBER]
";
var fieldFilterWhere = AdoHelper.BuildFilterStatement(FilterDescriptor.GetFilterList(filterExpression), "Processes", tableAlias: "[t0]");
var globalFilterWhere = AdoHelper.BuildFilterStatement(filter, new[] { "[t0].Name" });
var where = string.Format(CultureInfo.InvariantCulture, "WHERE IsRemoved = 0 {0} {1}", globalFilterWhere, fieldFilterWhere);
if (pageSize == 0)
{
pageSize = int.MaxValue;
}
var commandText = string.Format(CultureInfo.InvariantCulture, Sql, where, pageNumber * pageSize, pageSize);
using (var cmd = new SqlCommand(commandText, cn))
{
using (var reader = new SafeDataReader(cmd.ExecuteReader()))
{
while (reader.Read())
{
result.Add(
new PublishedProcessInfoDTO
{
ProcessId = reader.GetInt32(0),
Name = reader.GetString(1),
SystemName = reader.GetString(2),
IconId = reader.GetInt32(3),
ProcessGuid = reader.GetGuid(4),
});
}
}
}
using (
var cmdCount =
new SqlCommand(
string.Format(
CultureInfo.InvariantCulture,
"SELECT COUNT([t0].Id) FROM Processes [t0] JOIN [dbo].PublishedProcesses AS [t1] ON [t1].ProcessId = [t0].Id {0}",
where),
cn))
{
result.TotalRowCount = (int)cmdCount.ExecuteScalar();
}
}
return result;
}
示例9: FetchList
public IPagedList<ProcessInfoDTO> FetchList(string filter, int pageNumber, int pageSize, string filterExpression)
{
var result = new PagedList<ProcessInfoDTO>();
using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
{
var cn = ctx.Connection;
var sql = @"
DECLARE @p0 AS INT
SET @p0 = {1}
DECLARE @p1 AS INT
SET @p1 = {2};
SELECT [t1].[Id],
[t1].[Name],
[t1].[Description],
[t1].[Icon],
CASE
WHEN [t1].PublishedCopyId IS NULL THEN 0
ELSE 1
END AS IsPublished,
[t1].[SystemName],
[t1].[Guid],
[t1].[Color],
[t1].IsInactive,
[t1].IsSystem,
[t1].[Documentation]
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY [t0].[Name], [t0].[Id]) AS
[ROW_NUMBER],
[t0].[Name],
[t0].SystemName,
[t0].[Guid],
[t0].Id,
[t0].[Description],
[t0].[Documentation],
[t0].IsInactive,
[t0].IsSystem,
[i].Icon,
[c].Color,
(
SELECT id
FROM Processes p
WHERE p.Guid = [t0].Guid
AND p.IsPublishedCopy = 1
AND p.IsRemoved = 0
) AS PublishedCopyId
FROM [dbo].[Processes] AS [t0]
LEFT OUTER JOIN Icons i
ON [t0].IconId = [i].Id
LEFT OUTER JOIN Colors c
ON [t0].ColorId = [c].Id
{0}
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY
[t1].[ROW_NUMBER]
";
var fieldFilterWhere = AdoHelper.BuildFilterStatement(FilterDescriptor.GetFilterList(filterExpression), "Processes", tableAlias: "[t0]");
var globalFilterWhere = AdoHelper.BuildFilterStatement(filter, new[] { "[t0].Name", "[t0].Description" });
var where = string.Format(CultureInfo.InvariantCulture, "WHERE IsRemoved = 0 AND IsPublishedCopy = 0 {0} {1}", globalFilterWhere, fieldFilterWhere);
if (pageSize == 0)
{
pageSize = int.MaxValue;
}
var commandText = string.Format(CultureInfo.InvariantCulture, sql, where, pageNumber * pageSize, pageSize);
using (var cmd = new SqlCommand(commandText, cn))
using (var reader = new SafeDataReader(cmd.ExecuteReader()))
{
while (reader.Read())
{
result.Add(
new ProcessInfoDTO
{
Id = reader.GetInt32(0),
Name = reader.GetString(1),
Description = reader.GetString(2),
Icon = AdoHelper.ReadImage(reader, 3),
IsPublished = reader.GetInt32(4) != 0,
SystemName = reader.GetString(5),
Guid = reader.GetGuid(6),
ProcessColor = reader.GetInt64(7),
IsInactive = reader.GetBool(8),
IsSystem = reader.GetBool(9),
ProcessDocumentation = reader.GetString(10),
});
}
}
sql = string.Format(CultureInfo.InvariantCulture, "SELECT TotalRowCount = (SELECT COUNT(t0.Id) FROM Processes [t0] {0}), TotalActiveRowCount = (SELECT COUNT(t0.Id) FROM dbo.Processes t0 {0} AND t0.IsInactive = 0 AND t0.SimpleProcess = 0)", where);
using (var cmd = new SqlCommand(sql, cn))
using (var reader = new SafeDataReader(cmd.ExecuteReader()))
{
if (reader.Read())
{
//.........这里部分代码省略.........
示例10: GetRecentTracks
public IPagedList<ITrack> GetRecentTracks(string username, int? limit, int? page, Timestamp start, Timestamp end)
{
IApiMethod method = this.CreateApiMethod("user.getRecentTracks");
method.AddParameter("user", username);
if (page.HasValue)
{
method.AddParameter("page", page.ToString());
}
if (start != null)
{
method.AddParameter("from", start.GetUnixTimestamp());
}
if (start != null)
{
method.AddParameter("to", end.GetUnixTimestamp());
}
var response = method.Execute();
var tracks = (JArray)response["recenttracks"]["track"];
var attributes = response["recenttracks"]["@attr"];
IPagedList<ITrack> result = new PagedList<ITrack>();
result.Page = attributes.Value<int>("page");
result.PerPage = attributes.Value<int>("perPage");
result.TotalPages = attributes.Value<int>("totalPages");
result.Total = attributes.Value<int>("total");
foreach (var track in tracks)
{
result.Add(new Track { Url = track.Value<string>("url"), Name = track.Value<string>("name") });
}
return result;
}
示例11: TestFind
public void TestFind()
{
//arrange
var mockobject = new Mock<IRepository<Customer>>();
mockobject.Setup(r => r.Add(It.IsAny<Customer>()));
var customer = new Customer() { CustomerId = 1 };
mockobject.Setup<IEnumerable<Customer>>(r => r.Find(c => c.CustomerId == customer.CustomerId))
.Returns(new List<Customer>() { customer });
var mockPagedlist = new PagedList<Customer>() { PageSize = 10, PageIndex = 1, TotalCount = 50 };
for (int i = 0; i <= 10; i++)
{
mockPagedlist.Add(customer);
}
mockobject.Setup<IEnumerable<Customer>>(r => r.Find<int>(c => c.CustomerId == customer.CustomerId,c=>c.CustomerId,1,10))
.Returns(mockPagedlist);
var mockRepository = mockobject.Object;
//act
var clist = mockRepository.Find(c => c.CustomerId == customer.CustomerId);
var cPagedlist = mockRepository.Find<int>(c => c.CustomerId == customer.CustomerId,c=>c.CustomerId,1,10);
//assert
Assert.NotNull(clist);
Assert.True(clist.Count() > 0);
Assert.NotNull(cPagedlist);
Assert.Equal(10, cPagedlist.PageSize);
Assert.Equal(1, cPagedlist.PageIndex);
Assert.Equal(50, cPagedlist.TotalCount);
}
示例12: List
/// <summary>Fetch the score list for a given board.</summary>
/// <returns>Promise resolved when the operation has completed. The attached value describes a list of scores, and
/// provides pagination functionality.</returns>
/// <param name="board">The name of the board to fetch scores from.</param>
/// <param name="limit">The maximum number of results to return per page.</param>
/// <param name="offset">Number of the first result. Needs to be a multiple of `limit`. The special value of -1 can be used
/// to auto-select the page where the current logged in user is located, including his score in the result. After
/// that, you may use the paged result handler to fetch pages nearby.</param>
public Promise<PagedList<Score>> List(string board, int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v2.6/gamer/scores").Path(domain).Path(board).QueryParam("count", limit);
if (offset == -1) url.QueryParam("page", "me");
else url.QueryParam("page", offset / limit + 1);
return Common.RunInTask<PagedList<Score>>(Gamer.MakeHttpRequest(url), (response, task) => {
// Pagination computing
Bundle boardData = response.BodyJson[board];
int currentItems = boardData["scores"].AsArray().Count;
int total = Math.Min(boardData["maxpage"] * limit, offset + currentItems);
// Fetch listed scores
PagedList<Score> scores = new PagedList<Score>(response.BodyJson, offset, total);
int rank = boardData["rankOfFirst"];
foreach (Bundle b in boardData["scores"].AsArray()) {
scores.Add(new Score(b, rank++));
}
// Handle pagination
if (offset > 0) {
scores.Previous = () => List(board, limit, offset - limit);
}
if (offset + scores.Count < scores.Total) {
scores.Next = () => List(board, limit, offset + limit);
}
task.PostResult(scores);
});
}
示例13: List
/// <summary>
/// Can be used to list the active matches for this game. In general, it is not recommended to proceed this way
/// if your goal is to display the games that may be joined. The indexing API is better suited to this use case
/// (index the match along with properties and look for matches matching the desired properties).
/// </summary>
/// <returns>Promise resolved when the operation has completed. The list of matches filtered according to the
/// following parameters is provided.</returns>
/// <param name="participating">Set to true to only list matches to which this user is participating.</param>
/// <param name="invited">Set to true to filter by matches you are invited to (only include them).</param>
/// <param name="finished">Set to true to also include finished matchs (which are filtered out by default).</param>
/// <param name="full">Set to true to also include games where the maximum number of players has been reached.</param>
/// <param name="limit">For pagination, allows to set a greater or smaller page size than the default 30.</param>
/// <param name="offset">For pagination, avoid using it explicitly.</param>
public Promise<PagedList<MatchListResult>> List(bool participating = false, bool invited = false, bool finished = false, bool full = false, int limit = 30, int offset = 0)
{
UrlBuilder url = new UrlBuilder("/v1/gamer/matches");
url.QueryParam("domain", domain).QueryParam("offset", offset).QueryParam("limit", limit);
if (participating) url.QueryParam("participating");
if (finished) url.QueryParam("finished");
if (invited) url.QueryParam("invited");
if (full) url.QueryParam("full");
// Request for current results
return Common.RunInTask<PagedList<MatchListResult>>(Gamer.MakeHttpRequest(url), (response, task) => {
PagedList<MatchListResult> matches = new PagedList<MatchListResult>(response.BodyJson, offset, response.BodyJson["count"]);
foreach (Bundle b in response.BodyJson["matches"].AsArray()) {
matches.Add(new MatchListResult(b));
}
// Handle pagination
if (offset > 0) {
matches.Previous = () => List(participating, invited, finished, full, limit, offset - limit);
}
if (offset + matches.Count < matches.Total) {
matches.Next = () => List(participating, invited, finished, full, limit, offset + limit);
}
task.PostResult(matches);
});
}